Tuesday, March 10, 2020

New concepts of ES6

What is ES6 ?

It is an updated version of JavaScript that easier to use than older versions. It was released in 2011.

Older JS version vs ES6

1. Constant Variable
   
Constants are the values that can be defined only once. It's introduced to ES6. Therefore older versions don't have constant type variables.


* When run this in the console there will error. Because we can't add different values to the same constant variable.












2. Arrow Function

This type of function declaration. normally we were used to declaring the function with "function" keyword, return keyword and brackets. Inside the brackets, we have implemented the function. But in ES6 we can only use "=>", brackets and return keyword.

 If the function has a single statement you don't need to always use brackets and return function.

*Although try to use "const" rather than "var". because of a function expression always a constant value.


No comments:

Post a Comment