Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

new
es

What's new in ES 2019?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The evolution of JavaScript has been very impressive lately as several new features have emerged​ alongside every update.

svg viewer

Features of ECMA SCRIPT (ES 2019)

The following are the latest features; each feature is explained with a coded example:

1. Array.flat()

This method recursively builds an array using all of the subarrays.

var myarr=[1,2,3,4[5,6,7,[8,9],10]]
myarr.flat(Infinity)
console.log(myarr)

The output would be:

[1,2,3,4,5,6,7,8,9,10]

2. Array.flatMap()

This method takes the specific pattern as an argument and applies it to each element in the array; it stores the output in the same array that ​it was called on.

var myarr=[1,2,3,4,5]
myarr.map(x => [x * 2])
myarr.FlatMap(x => [x * 2])
console.log(myarr)

The output would be:

[1,2,2,4,3,6,4,8,5,10]

3. String.trimStart() & String.trimEnd()

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

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

var text=[' Hello User ']
console.log(text.trimStart())
console.log(text.trimEnd())

The output would be:

'Hello User    '
'    Hello User'

4. Optional Catch Binding

It allows developers to use try/catch without creating an unused binding. Developers are given the functionality to make use of catch bloc, without a parameter.

try {
throw new Error ('an error')
}
catch {
console.error('No parameter used for catch')
}

The output would be: No parameter used for catch

5.Function.toString()

The toString() method returns a string that represents the source code of the function. Earlier white spaces, new lines, and comments will be removed, but​ they are retained within the original source code.

var mystring = new String("Hello User");
console.log(mystring);
console.log(mystring.toString());

The output would be:

[String: 'Hello User']
Hello User

RELATED TAGS

new
es
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring