# ECMAScript 2019 (ES10)¶

## Array.flat()¶

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

const numbers = [1, 2, [3, 4, [5, 6]]];
// default depth is 1
numbers.flat();
> [1, 2, 3, 4, [5, 6]]


## Array.flatMap()¶

The flatMap() method first maps each element using a mapping function, then flattens the result into a new array. It is identical to a map followed by a flat of depth 1, but flatMap is often quite useful, as merging both into one method is slightly more efficient.

const numbers = [1, 2, 3];
numbers.flatMap(x => [x * 2]);
> [2, 4, 6]


## Object.fromEntries()¶

The Object.fromEntries() method transforms a list of key-value pairs into an object.

const records = [['name','Mathew'], ['age', 32]];
const obj = Object.fromEntries(records);
> { name: 'Mathew', age: 32}


## String.trimStart() and String.trimEnd()¶

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

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

You can think why another new method already there are two method trimRight()and trimLeft() but it will be alias of above new methods

## Optional Catch Binding¶

Allow developers to use try/catch without creating an unused binding. You are free to go ahead make use of catch block without a parameter.

try {
...
} catch {
...
}


## Function.toString()¶

The toString() method returns a string representing the source code of the function.Earlier white spaces,new lines and comments will be removed when you do now they are retained with original source code

## Symbol.description¶

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

## Well Formed JSON.Stringify()¶

To prevent JSON.stringify from returning ill-formed Unicode strings.

## Array.Sort Stability¶

Elements with same sort value retain their order. It now uses always the stable TimSort algorithm.

## JSON ⊂ ECMAScript (JSON Superset)¶

The line separator (U+2028) and paragraph separator (U+2029) symbols are now allowed in string literals. Previously, these were treated as line terminators and resulted in SyntaxError exceptions.