New Global Methods
ES6 added 2 new global number methods:
- isFinite() Method: It checks if a value is a finite number, returning true for numbers, excluding NaN and Infinity.
- isNaN() Method: It checks if a value is Not-a-Number (NaN), returning true if it’s NaN, false otherwise.
Example: In this example we are using the above-mentioned methods.
Javascript
const var1 = 12; const var2 = "Geeks" ; const var3 = NaN; const var4 = Infinity; console.log(isFinite(var1)); console.log(isFinite(var2)); console.log(isNaN(var1)); console.log(isNaN(var2)); console.log(isNaN(var3)); console.log(isFinite(var3)); console.log(isFinite(var4)); |
Output
true false false true true false 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