The mobile app development company Algoworks has listed here a few updates of the ES6, with the upcoming time ECMAScript is bound to have a tremendous impact in the world of web development.
Popular ECMAScript6 features
In ES6 while declaring variables like var, you are liable to use LET now. However, the difference lies in the scope of use. Var is used in case of a variable where the surrounding function is the scope and when you use to let the variable scope is restricted only to the block it is in.
However with a few variables writing a clean code is also possible, let’s look at the array iteration code provided below:
In an ideal situation, you would attempt to use ‘j’ variable for another iteration within the same scope but by using let variable ‘i’ is defined and is ready for reuse as it is available only on the block.
The above code can be rewritten as:
To simplify let’s take the help of an example:
In the code mentioned above as we can see there are N number of export statements and each export system clearly state the type (function and var) of the exported value.
Again while destructuring the import statement it explicitly defines what is being imported.
The module features a default export , however you just need to provide the local name in order to import the default value into the module.
Though the import statements are synchronous, the code of the module does not execute until all the dependencies have been loaded.
Like numbers and string are a new primitive data type, symbols allow the properties to be keyed by using either string or symbol. Symbols are unique but not private as they are displayed through reflection features.
Some more features
ECMAScript6 is not just the five features stated above but there are a lot more to it. It comprises of myriad other features that are worth the bet, which involves Destructuring, Generators, Template literals, Spread Operator and a lot more. While Destructuring involves extraction of values from stored data in objects and Arrays, Generators on the other hand aids in pausing and resuming functions.