📎 Webclip
10 New JavaScript Features in ES2020 That You Should Know
The post says ES2020 is now finalized and gives a tour of the main changes in the JavaScript specification. It focuses on features for larger integers, cleaner module loading, safer property access, and more consistent behavior across runtimes.
Reading notes#
- BigInt lets JavaScript represent integers beyond the current
2^53 - 1limit, and values use annsuffix to mark them as BigInts. - Dynamic import lets applications load modules on demand, including conditional loading, without relying on bundlers like Webpack or Babel.
- Nullish coalescing checks only
undefinedandnull, instead of all falsey values, so empty strings and0can still be kept. - Optional chaining reads deeply nested properties, function calls, or array access without throwing when an intermediate value is missing.
- Promise.allSettled waits until every promise is settled, whether resolved or rejected.
- String#matchAll returns an iterator with all regex matches and captured groups.
- globalThis provides one global object name that works in browsers, Node, web workers, and other runtimes.
- Module namespace exports add symmetric syntax such as
export * as utils from './utils.mjs'. - The order of
for...inloops is now formally defined in ES2020. import.metagives module metadata, including aurlproperty for the module base URL.
