![]() |
VOOZH | about |
JavaScript 2009 (ES5) refers to the fifth edition of the ECMAScript language specification, standardized in 2009. It introduced several features, like strict mode, new methods, JSON support, and improved syntax for better programming practices and compatibility across browsers.
ECMAScript 5 (ES5) introduced several significant features to JavaScript, enhancing the language's capabilities.
Name | Description |
|---|---|
Enforces stricter parsing and error handling in JavaScript code. | |
Removes whitespace from the beginning and end. | |
Use backslashes at the end of each line to continue. | |
Check if an object is an array. | |
Iterates over array elements, applying a provided function. | |
Transforms each array element using a provided function. | |
Creates a new array with elements passing a test. | |
Combines an array of elements to produce a single result. | |
Combines array elements from right to left. | |
Checks if all elements satisfy a given condition. | |
Checks if any element satisfies a given condition. | |
Returns the index of a specified element. | |
Returns the last index of a specified element. | |
Converts JSON string to JavaScript object. | |
Converts JavaScript object to JSON formatted string. | |
Returns the current timestamp in milliseconds since 1970. | |
Converts date to ISO 8601 format string. | |
Converts date to JSON-formatted string (ISO 8601). | |
Property Getters and Setters | Control object property access and modification behavior. |
Defines or modifies a property's attributes on an object. | |
Defines or modifies multiple properties' attributes on an object. | |
Gets attributes of a property from an object. | |
Returns an array of enumerable property names in object. | |
Returns an array of all property names in object. | |
Prevents adding new properties to an object. | |
Checks if new properties can be added. | |
Prevents new properties and makes existing non-configurable. | |
Checks if object properties are non-configurable and sealed. | |
Prevents adding, modifying, and makes properties non-writable. | |
Checks if object properties are non-writable, non-configurable, and frozen. |
Here is the explanation of above-mentioned topic
The use strict enforces strict mode in JavaScript, catching errors and promoting better coding practices. It's used at the beginning of scripts or functions.
Syntax:
// Whole-script strict mode syntax
'use strict';
let v = "strict mode script!";
Example: In this example we are using the above-explained method.
Output:
ReferenceError: result is not definedJavaScript String trim() method is used to remove the white spaces from both ends of the given string.
Syntax:
str.trim()Example: In this example we are using the above-explained method.
GeeksforGeeks
In ES5, multiline strings can be created using backslashes at the end of each line to continue, combined with + for concatenation, to form a single string across lines.
Syntax:
line one\n\
line two\n\
Example: In this example we are using backslashes and + to write Multiline strings.
GeeksforGeeks A computer science Portal. GeeksforGeeks
Syntax:
Array.isArray(obj)
map((element) => { /* … */ })
array.filter(callback(element, index, arr), thisValue)
array.reduce( function(total, currentValue, currentIndex, arr), initialValue )
Example: In this example we are using the above-explained methods.
Is 'numbers' an array? true doubling each elemen of our array : [ 2, 4, 6, 8, 10 ] Even numbers from the array: [ 2, 4 ] Sum of all elements in the array: 15
The JSON.parse() method is a JavaScript method that converts a JSON string into a JavaScript object.
Syntax:
JSON.parse( string, function )Example: Here is the basic example of JSON.parse() method.
Aman 21 Noida
JSON.stringify() is a JavaScript method that converts a JavaScript object into a JSON string for data serialization and storage.
Syntax:
JSON.stringify(value, replacer, space);Example: In this example we are using JSON.stringify().
value of result = {"Company":"GeeksforGeeks","Estd":2009,"location":"Noida"}
Syntax:
let A = Date.now(); // Date.now()
dateObj.toISOString() // Date toISOString()
dateObj.toJSON() // Date toJSON()
Example: In this example we are using the abobe-explained methods.
Timestamp: 1698213643835 ISO String: 2023-10-25T06:00:43.835Z JSON Date: 2023-10-25T06:00:43.835Z
In ECMAScript 5 (ES5), property getters and setters enable defining custom behavior when reading (get) or modifying (set) object properties, enhancing encapsulation and control over property access.
Example: In this example we are using the above-explained approach.
John Doe Jane Smith
ECMAScript 5 introduced new object methods
It enhance the object property control, definition, and manipulation.
Syntax:
Object.defineProperty(obj, prop, descriptor) // Object.defineProperty()
Object.defineProperties(obj, props) // Object.defineProperties()
Object.getOwnPropertyDescriptor( obj, prop ) // Object.getOwnPropertyDescriptor()
Object.keys(obj); // Object keys() Method
Example: In this example we are some mentioned method.
Property Names: [ 'name', 'age', 'gender' ]
All Property Names: [ 'name', 'age', 'gender' ]
Is Extensible: false
Is Sealed: true
Is Frozen: true
{ name: 'Ankit', age: 21, gender: 'Male' }