ES6…hmmm?
First of all, it should be understood that ES6 is not entirely supported by browsers so certain compilers/polyfills or transpilers like babel and module bundlers like webpack might be needed, which converts the ES6 to ES5 understandable by the browsers!
So…what is ES6 ?
ES6 — ECMAScript2015 or ECMAScript 6 …
ECMAScript is a Standard for scripting languages. Languages like Javascript are based on the ECMAScript standard.
Lets see what the new features this version of ECMAScript offers over the ES5!
(1) let , const, var
Basically, the difference if you’ve not understood by now is that you can create block scopes in JS now using thelet
keyword !!
And, constants can be created using const
keyword
Also, something worth noting is …
How is this happening! 😮 I just said const
creates a constant, then how am I able to change the values ???
const nums = [10, 20, 30]
here nums is pointing to the array [10, 20, 30]
so it’s logical that we can modify / add values into the array!
Same concept is followed when object literals are defined!
(2) Fat Arrow functions :
It’s kinda self-explanatory how it works! :)
(3) Object Literal Extensions :
(4) Deconstruction :
(5) The rest operator :
(6) The spread Operator :
The spread operator basically converts your array nums into single elements !
Note that the syntax for both “The Spread and Rest operators are similar” !
(7) For-of Loop :
(8) Template Literals :
There are many other things that I have not discussed here, but these are some really useful features ES6 provides over ES5!