ECMAScript 2020 introduces various attributes ranging from a new
import() facility for loading modules to a new
BigInt type for doing work with arbitrary precision integers.
Particular attributes released by ECMAScript 2020 include:
- A “function-like”
import()module loading syntax to asynchronously import modules with a dynamic specifier. The proposal adds an
import(specifier)syntactic sort, performing in numerous techniques like a functionality. It returns a guarantee for the module namespace item of the requested module, made following fetching, instantiating, and assessing a module’s dependencies, alongside with the module by itself. The
specifierwill be interpreted the similar way as in an
specifieris a string, it is not necessarily a string literal so, code like
import(`./language-packs/$navigator.language.js`)will function. This was not doable with the typical
importdeclarations. With the plan,
import()is proposed to function in both of those modules and scripts, offering script code an simple asynchronous entry issue into the module planet and enabling it to get started operating module code.
BigInt,a new variety primitive for doing work with arbitrary precision integers.
BigIntis made by appending
nto the conclude of the integer or by calling the constructor.
matchAllprocess for strings, to develop an iterator for all matched objects created by a world wide frequent expression. The rationale behind this proposal is that if a developer has a string and possibly a sticky or a world wide frequent expression with various capturing groups, the developer could want to iterate through all the matches, for which there are at this time quite a few options but with restrictions.
String#matchAlladdresses issues by offering accessibility to all capturing groups and not visibly mutating the frequent expression item in question.
Promise.allSettled, a new Promise combinator that does not quick-circuit. This returns a guarantee that is fulfilled with an array of guarantee state snapshots, but only following the initial claims have settled, i.e. have been possibly fulfilled or rejected.
globalThis, offering a universal way to accessibility the world wide
- A focused
export * as ns from ‘module’syntax to use inside modules.
- Enhanced standardization of
- Nullish coalescing, a value collection operator for superior dealing with of circumstances involving residence accesses. It is a syntax characteristic to boost doing work with “nullish” values (
- Optional chaining, a residence accessibility and functionality invocation operator that will quick-circuit if the value to accessibility/invoke is nullish.
The past update to ECMAScript, ECMAScript 2019, showcased capabilities these kinds of as
prototype.flatMap for nested arrays.
Copyright © 2020 IDG Communications, Inc.