EcmaScript

Mohd ImranMohd Imran
2 min read

EcmaScript is nothing but an advanced version of javascript. In 1995 when they develop javascript as a client-side scripting language they promised that they will add new features every year and would call ECMAScript so whenever they add new features the ECMAScript version was updated as well but till 2014 they update ECMAScript version only five times after 2014 when ECMAScript version 6 in 2015 they added many features that made javascript popular in night EcmaScript version 6 features are

  • let and const (constant)

  • fat arrow function

  • string.includes

  • default parameters

  • for of loop and for in loop

  • etc.... read more

let and const

let

let variable has block scope, cannot reassign, and must be declared before use.

const

const variable has also a block scope, cannot reassign, cannot redeclare, and must be declared before use.

var-let-const-cheatsheet.jpg

fat arrow function

Before ECMAScript 6 everyone used standard function in ES6 (EcmaScript 6) they introduced fat arrow function. we have to declare the fat arrow function before calling and if your statement inside the function comes in one line so you do not need to write return keyword and curly bracket.

Example

1_OirA6iFZ1yte0T-QyVeTvQ.png

string.includes

string.includes return boolean value it takes a string and shows whether the string is included or not.

Example

var greeting="Good morning Mr.Joker"
greeting.includes("morning") // true

default parameters

ES6 allows function parameters to have default values.

Example

function myFunction(x, y = 10) { // y is 10 if not passed or undefined return x + y; } myFunction(5); // will return 15

for of loop

for of loop statement run the loop over the array and return elements of the array.

Example

var fruits=["mango" , "apple" , "graps"]

for(let elements of fruits)
{
console.log(elements)
}
// output
mango
apple
graps

for in loop

for of loop statement run the loop over the array and return index number of the array.

Example

var fruits=["mango" , "apple" , "graps"]

for(let elements in fruits)
{
console.log(elements)
}
// output
0
1
2

1
Subscribe to my newsletter

Read articles from Mohd Imran directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mohd Imran
Mohd Imran