ES10 Features

5/20/2019
ยท 3 min read

Here are the new features of es2019/es10, taken from a thread written by Aurelie AMBAL (a French javascript lead developer โœŒ๏ธ).

ES10 is not as significant as ES6 in terms of new language features but it does add several interesting ones. My favorite is definitely the Object.fromEntries one!

String.matchAll()

Given a string and a regular expression, matchAll() returns an iterator for the match objects of all matches.

String.matchAll()

Array.flat() & Array.flatMap()

The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.

The flatMap() method maps each element using a mapping function and flattens the result into a new array.

Array.flat()
Array.flatMap()

Dynamic import

Imports can now be assigned to a variable!

Dynamic import

Object.fromEntries()

The Object.fromEntries() method transforms a list of key-value pairs into an object. It can be used to perform the reverse of Object.entries()

Object.fromEntries()

string.trimStart & string.trimEnd

The trimStart() method removes whitespace from the beginning of the string.

The trimEnd() method removes whitespace from the end of a string.

TrimStart() or trimLeft() do not affect the value of the string itself.

string.trimStart & string.trimEnd

Symbol.prototype.description()

The read-only description property is a string returning the optional description of Symbol objects.

It is different than Symbol.prototype.toString() as it does not contain the enclosing "Symbol()" string.

Symbol.prototype.description()

Optional Catch Binding

In the past catch clause from a try/catch statement required a variable.
Now it allows developers to use try/catch without creating an unused binding.

You are free to make use of catch block without a param!

Optional Catch Binding

Well-Formed JSON.Stringify()

This update fixes processing of characters U+D800 through U+DFFF and prevent JSON.stringify from returning ill-formed Unicode strings.

Well-Formed JSON.Stringify()

Array.sort Stability

The previous implementation of V8 used an unstable QuickSort algorithm for arrays containing more than 10 elements.

But this is no longer the case. ES10 uses a stable TimSort algorithm.

In this example, Users with same value retain their sorting order.

Array.sort Stability

toString() changes

The toString() method returns a string representing the source code of the function.

Earlier white spaces, new lines, and comments were removed, now they are retained with original source code.

toString() changes

Standardized globalThis object

ES10 added the globalThis object which should be used from now on to access global scope on any platform:
The global globalThis property returns the top level global object.

Standardized globalThis object

You can see all the Finished Proposals here: https://github.com/tc39/proposals/blob/master/finished-proposals.md

[THREAD]

JavaScript new features in ECMAScript 2019 (ES2019)/ES10

All listed in one thread with description and visual examples!

433 people are talking about this

You can find this page with theses search keywords:

/ es2019 /
Mathieu TUDISCO
Thanks for reading!
I'm Mathieu TUDISCO, a lead developer at Linkvalue .
You can find me anywhere with @mathieutu.
As a start you can follow me on Twitter or want to find out more about me or the blog.