New Number Methods
- Number.isInteger() Method: It checks if a value is an integer, returning true if it is, false otherwise.
- Number.isSafeInteger() Method: It verifies if a value is within the range of safe integers, preventing precision loss.
Example: In this example we are using the above-mentioned method.
Javascript
const num1 = 42; const num2 = 3.14; const num3 = 9007199254740992; // Largest safe integer console.log(Number.isInteger(num1)); console.log(Number.isInteger(num2)); console.log(Number.isSafeInteger(num1)); console.log(Number.isSafeInteger(num3)); |
Output
true false true false
JS 2015 or ECMAScript 6 (ES6)
JS 2015 (ES6) also known as ECMAScript 6 (ES6), ECMAScript 6 (ES6) is a significant update to JavaScript, introducing arrow functions, classes, template literals, let and const for variable declaration, enhanced object literals, destructuring, and more modern features for better code organization and readability.
Contact Us