ECMA Script

ECMA Script / ES6 / Modern JS

In 1996 JavaScript was created. In 1997 it was then submitted to ECMA International for standardization, which resulted in ECMAScript.

note

Variables declared with "var" in JavaScript are function scoped. Variables declared with "let and const" are block scoped.

EC6 features

Template Literals or Template Strings (` `)

E.g.

let fName = “Shresth”;
let lName = “Srivastava”;
console.log(`My first name is $(fName). My Last name is ${lName}`)

Template Literals methods:

alt text

Array Destructuring:

alt text

Swap two number without using third variable: alt text

Object Destructuring:

alt text

Arrow Functions / Fat Arrow Functions:

alt text alt text

Default Parameter:

alt text

Here b=2 and c=2 is given in function parameter is called default parameter.

Rest Parameter (…):

alt text alt text alt text

Spread Operator:

Syntax of Spread operator is similar as Rest Parameter but it works differently.
It replaced apply() and concat() and copy() method in javascript.

alt text alt text alt text

Exponentiation Operator (**):

alt text

Above example will return 25 as output. Same thing we can do with Math.pow(a,b)

async/await:

alt text alt text

Error handling:

alt text