Earlier ECMAScript versions were named by numbers, such as ES5 and ES6. Starting in 2016, versions are named after their release year, like ES2016, ES2018, ES2020, and so on.
Warning: These features are relatively new, so older browsers may require alternative code or a polyfill for compatibility. |
JavaScript BigInt variables are used to store integer values that exceed the size limit of regular JavaScript Number values. JavaScript integers are only precise up to about 15 digits.
let x = 999999999999999; let y = 9999999999999999; // too big |
let x = 9999999999999999; let y = 9999999999999999n; |
To create a BigInt, either append n to the end of an integer or use the BigInt() constructor.
let x = 1234567890123456789012345n; let y = BigInt(1234567890123456789012345) |
The typeof a BigInt in JavaScript is “bigint”.
let x = 1234567890123456789012345n; let y = BigInt(1234567890123456789012345) |
Prior to ES2020, there was no string method available to find all instances of a substring within a string.
const iterator = text.matchAll(“Cats”); |
If the parameter is a regular expression, the global flag (g) must be enabled; otherwise, a TypeError will be thrown.
const iterator = text.matchAll(/Cats/g); |
To perform a case-insensitive search, the “i” flag must be applied.
const iterator = text.matchAll(/Cats/gi); |
The ?? operator returns the first argument if it is not null or undefined; otherwise, it returns the second argument.
let name = null; let text = “missing”; let result = name ?? text; |
All modern browsers have supported the nullish coalescing operator since March 2020.