ECMAScript 2020 introduces multiple features ranging from a new
import() facility for loading modules to a new
BigInt type for doing the job with arbitrary precision integers.
Specific features prepared for ECMAScript 2020 contain:
- A “function-like”
import()module loading syntax to asynchronously import modules with a dynamic specifier. The proposal provides an
import(specifier)syntactic sort, acting in numerous strategies like a functionality. It returns a promise for the module namespace object of the asked for module, established soon after fetching, instantiating, and assessing a module’s dependencies, alongside with the module alone. The
specifierwill be interpreted the exact way as in an
specifieris a string, it is not essentially a string literal therefore, code like
import(`./language-packs/$navigator.language.js`)will do the job. This was not achievable with the regular
importdeclarations. With the plan,
import()is proposed to do the job in both of those modules and scripts, giving script code an straightforward asynchronous entry stage into the module earth and allowing for it to start off functioning module code.
BigInt,a new range primitive for doing the job with arbitrary precision integers.
BigIntis established by appending
nto the end of the integer or by contacting the constructor.
matchAllstrategy for strings, to deliver an iterator for all matched objects produced by a international regular expression. The rationale powering this proposal is that if a developer has a string and possibly a sticky or a international regular expression with multiple capturing teams, the developer could possibly want to iterate as a result of all the matches, for which there are presently many selections but with limitations.
String#matchAlladdresses concerns by furnishing entry to all capturing teams and not visibly mutating the regular expression object in question.
allSettled, a new Guarantee combinator that does not shorter-circuit. This returns a promise that is fulfilled with an array of promise condition snapshots, but only soon after the original claims have settled, i.e. have been possibly fulfilled or rejected.
globalThis, furnishing a common way to entry the international
- A focused
export * as ns from ‘module’syntax to use in just modules.
- Increased standardization of
- Nullish coalescing, a price range operator for better managing of scenarios involving residence accesses. It is a syntax function to increase doing the job with “nullish” values (
- Optional chaining, a residence entry and functionality invocation operator that will shorter-circuit if the price to entry/invoke is nullish.
The past update to ECMAScript, ECMAScript 2019, featured abilities this kind of as
prototype.flatMap for nested arrays.
Copyright © 2020 IDG Communications, Inc.