The method isn’t new, but it was revised. Now the
toString() method returns
source code of the applied function as it is – with all white spaces, new lines,
and comments. Earlier they were removed.
Array.prototype.flat() and Array.prototype.flatMap()
Array.prototype.flat() creates a new flattened array by turning the specified
array of values which may be more arrays to the defined depth. By default, the
depth value is
1. You can use
Infinity value to create a one-dimension array.
Array.prototype.flatMap() is a kind of mix between
array.map(). The method maps each element via the specified function first
and then creates a new array and fills it by flattening the result.
String.prototype.trimStart() and String.prototype.trimEnd()
String.prototype.trimStart() removes the whitespace characters from the
beggining of a string and string.prototype.trimEnd() removes them from the end.
There are identical methods
string.trimRight() that are
aliases of the
The method converts a list of key-value pairs into an object. It only accepts iterable objects (Array or Map).
Earlier an array that has more than 10 items used unstable QuickSort algorithm. Now stable TimSort is used instead.
Optional catch parameter in try…catch
The method allows not to specify the unused binding (parameter) of the catch clause.
Prior to ECMAScript 2019, to get a description we used
toString() method. Now
we have an intuitive read-only
description property - a string returning the
optional description of Symbol objects.
Improved JSON.stringify() formatting
JSON.stringify() is prevented from returning lone surrogates without
representation them in UTF-8 standard. Since lone UTF-16 surrogates cannot be
encoded as UTF-8, ECMAScript 2019 represents them with JSON escape sequences.
Now the JSON subset is a part of ECMAScript syntax. It’s a more specific update and doesn’t provide new features but fix old bugs.