ECMAScript 2019, the latest version of the specification serving as the basis of JavaScript, has been finalized. ECMA International approved the specification in June.
The new features introduced in ECMAScript 2019 include the following:
Symbol.prototype.description
, an accessor property whoseset accessor
is undefined. Itsget accessor
function performs steps including: Lets
be this value, letsym
be?
thisSymbolValue(s)
, and returnsym
.[[Description]]
. The goal of this feature is to expose the[[Description]]
internal slot of a symbol directly instead of only indirectly throughSymbol.prototype.toString
.- Changes to
Function.prototype.toString
. Revisions have been proposed such as implementations not being required to retain source text for all functions defined using ECMAScript code. prototype.flatMap
, a common array operation that takes a nested array structure and removes one or more levels of nesting depending on its parameter. Flat exists in array-like libraries like Lodash, which has led users to want the same functionality in vanilla JavaScript.prototype.flatmap
, a map followed by a flat, offers a slight convenience and slight optimization. Flatmap is convenient because flattening and mapping often are useful in the same operation. It also is an optimization because there is no need to allocate an array for the mapping just to discard it when flattening.prototype.sort()
, a method that sorts the elements of an array in place and returns the array, is now stable.Object.fromEntries
, providing for a new static method to transform a list of key value pairs to an object.String.prototype.trimStart
andString.prototype.trimEnd
. The rationale behind these revisions is that all major engines have implemented correspondingtrimLeft
andtrimRigh
t functions without a standard specification. For consistency withpadStart/padEnd
,trimStart
,trimEnd
,trimLeft
, andtrimRight
are being proposed as aliases for web compatibility.- Updates to
JSON.stringify
to emit well-formed UTF-16 (Unicode Transformation Format). Currently, ill-formed code units might be emitted for surrogate code points. - Optional
catch
binding, allowing developers to omit acatch
binding when the binding would not be used.
The full ECMAScript 2019 specification can be viewed online at the ECMA International website. It also can be downloaded. Completed ECMAScript editions typically are published each June, such as last year’s ECMAScript 2018 specification.