ECMAScript roadmap: New JavaScript features for 2019

The committee overseeing ECMAScript has approved the specification for the next edition of JavaScript

ECMAScript roadmap: New features for 2019
pxhere (CC0)

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 whose set accessor is undefined. Its get accessor function performs steps including: Let s be this value, let sym be ? thisSymbolValue(s), and return sym.[[Description]]. The goal of this feature is to expose the [[Description]] internal slot of a symbol directly instead of only indirectly through Symbol.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 and String.prototype.trimEnd. The rationale behind these revisions is that all major engines have implemented corresponding trimLeft and trimRight functions without a standard specification. For consistency with padStart/padEnd, trimStart, trimEnd, trimLeft, and trimRight 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 a catch 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.

Copyright © 2019 IDG Communications, Inc.