While ECMAScript 2020 introduces some new features ranging from the import() facility for loading modules and the BigInt type for working with arbitrary precision integers.
The proposal also adds an import(specifier) syntactic form, which acts in many ways to return a promise for the module namespace object, created after fetching, and evaluating a module’s dependencies.
What's new in ECMAScript 2020?
The matchAll method for strings, String#matchAll which produces an iterator for all matched objects generated by the global regular expression is another important new feature.
If a developer, for instance, has either a sticky or a global regular expression with multiple capturing groups, and the developer wants to iterate through all the matches, there are currently several options but with limitations. String#matchAll addresses the issues by providing access to all the capturing groups and won't visibly mutate the regular expression object.
ECMAScript 2020 brings multiple of other new features, including:
- globalThis provides a universal way to access the global this value.
- Dedicated export * as ns from ‘module’ syntax to use with modules.
- Nullish coalescing is a value selection operator for handling cases involving property accesses, with a syntax feature for working with “nullish” values (null or undefined).
- Optional chaining offers property access and function invocation operator that short-circuit the value to access/invoke if null.
Additionally, there is a new Promise combinator, dubbed Promise.allSettled, that does not short-circuit. It returns a promise that's fulfilled with an array of promise state snapshots, but only after the original have settled, that is, it has been either fulfilled or rejected.
ECMAScript 2020 specification is developed on GitHub with the help of the ECMAScript community and there are several ways to contribute to the development of this specification as enumerated here.