ECMAScript 2020 introduces various characteristics ranging from a new
import() facility for loading modules to a new
BigInt type for performing with arbitrary precision integers.
Certain characteristics introduced by ECMAScript 2020 consist of:
- A “function-like”
import()module loading syntax to asynchronously import modules with a dynamic specifier. The proposal provides an
import(specifier)syntactic form, performing in a lot of ways like a functionality. It returns a assure for the module namespace item of the asked for module, designed right after fetching, instantiating, and assessing a module’s dependencies, alongside with the module alone. The
specifierwill be interpreted the identical way as in an
specifieris a string, it is not essentially a string literal thus, code like
import(`./language-packs/$navigator.language.js`)will get the job done. This was not possible with the normal
importdeclarations. With the program,
import()is proposed to get the job done in each modules and scripts, offering script code an straightforward asynchronous entry place into the module globe and enabling it to start running module code.
BigInt,a new number primitive for performing with arbitrary precision integers.
BigIntis designed by appending
nto the stop of the integer or by contacting the constructor.
matchAllapproach for strings, to produce an iterator for all matched objects created by a world normal expression. The rationale powering this proposal is that if a developer has a string and possibly a sticky or a world normal expression with various capturing teams, the developer might want to iterate by way of all the matches, for which there are at the moment numerous options but with limitations.
String#matchAlladdresses concerns by supplying obtain to all capturing teams and not visibly mutating the normal expression item in problem.
Guarantee.allSettled, a new Guarantee combinator that does not quick-circuit. This returns a assure that is fulfilled with an array of assure point out snapshots, but only right after the unique promises have settled, i.e. have been possibly fulfilled or turned down.
globalThis, supplying a common way to obtain the world
- A focused
export * as ns from ‘module’syntax to use in modules.
- Increased standardization of
- Nullish coalescing, a benefit choice operator for improved handling of circumstances involving house accesses. It is a syntax characteristic to boost performing with “nullish” values (
- Optional chaining, a house obtain and functionality invocation operator that will quick-circuit if the benefit to obtain/invoke is nullish.
The previous update to ECMAScript, ECMAScript 2019, showcased capabilities these types of as
prototype.flatMap for nested arrays.
Copyright © 2020 IDG Communications, Inc.