BigInt
BigInt is a built-in object in JavaScript that provides a way to represent whole numbers larger than 253-1.
Syntax:
BigInt( number )
or
Appending n to end of an integer literal
Example: Here is the basic example of above-method.
Javascript
// Parameter in decimal format let bigNum = BigInt( "123422222222222222222222222222222222222" ); console.log(bigNum); // Parameter in hexadecimal format let bigHex = BigInt( "0x1ffffffeeeeeeeeef" ); console.log(bigHex); // Parameter in binary format let bigBin = BigInt( "0b1010101001010101001111111111111111" ); console.log(bigBin); |
123422222222222222222222222222222222222n 36893488074118328047n 11430854655n
JS 2020 – ECMAScript 2020
JavaScript ECMAScript 2020 (ES11) introduced new features like optional chaining, nullish coalescing, dynamic import(), BigInt, and Promise.allSettled(), etc. enhancing language capabilities for modern web development needs.
JavaScript 2020 (ES11) or ECMAScript 2020 new features are:
BigInt |
type for arbitrary precision integers beyond the Number’s limit. |
String matchAll() |
returns an iterator for all regex matches in the string. |
The Nullish Coalescing Operator (??) |
returning right operand if the left is nullish, else left. |
The Optional Chaining Operator (?.) |
accessing nested properties if they exist, otherwise returns undefined. |
Logical AND Assignment Operator (&&=) |
assigns the right operand to the left if the left is truthy. |
Logical OR Assignment (||=) |
assigns the right operand if the left is falsy, else left. |
Nullish Coalescing Assignment (??=) |
the operator assigns the right operand if the left is nullish, else left. |
Promise allSettled() |
returning an array of promise results with status and value. |
Dynamic Import |
enables asynchronous import of modules at runtime. |