# ES10 Features
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.
# 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.
# Dynamic import
Imports can now be assigned to a variable!
# 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()
# 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.
# 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.
# 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!
# 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.
# 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.
# 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.
# 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.
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!
You can find this page with theses search keywords: