use strict
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.
Javascript
"use strict" ; function strictFunction(a, b) { // Throws an error in strict mode //due to the undeclared variable "result" result = a + b; return result; } let sum = strictFunction(5, 10); console.log( "Sum of the given numbers :" , sum); |
Output:
ReferenceError: result is not defined
JavaScript ES5 (JS 2009)
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
Contact Us