Intro to the added feature of js (ES6).
let
let create mutable variables. This means, after declaring its value can be changed or updated and take new values. It is a blocked scope, which means you can’t access it from the outside of its scope.
const
const is a new keyword in es6. It is more useful than var. If you assign a const variable once, it can’t reassign the value. So it is an immutable variable. But when its uses as an object, then properties can be reassigned. For its immutable condition, it is really helpful to use to target an object from the DOM. It is also blocked scope like let.
Arrow function
The arrow function does the same thing as the function. But it is a new syntax for writing a function in es6. It looks better, easier to read, and makes the code more structured. It can be used with built methods like map, filter, and reduce.
For/Of loop
Looping through an object, became easier with ES6 for/of loop. This statement loops through the values of iterable objects. Like you can access an element from an array, stings, or map for each data each time iteration without manually iterate index and access from the array each time by the index.
Default parameters
Operating function with default parameter is easier. You can pass an empty parameter for function, your code won’t throw an error, because es6 defined a default parameter for you.
Object destructing
With destructing, it is easier to assign values of an array object. In previous, we assigned each value for each variable. In es6, we just use to put values in curly brackets to get a property.
Import and export
Javascript application is more powerful with import-export. It is needed to work with different file components. You can export a module from one component and import it from another component. For that, it is easier to maintain the flexibility of large applications.
Promises
Promises are also a new feature of ES6. You will need it to write asynchronous code. Like if you are fetching data from an API, or a code block is taking time to finish. Promises will release the thread and help code to run efficiently.
Spread operator
The spread operator comes in handy to manipulate arrays. It used to take all elements from the arrays with all arguments, then we can add more values in the array by keeping the previous data and make a new variable. Without a spread operator, this task needs to use for loop and we can get rid of it by using spread operatior.
Classes
When it comes to object-oriented programming(OPP), classes are the core. They make your code more secure and encapsulated. It’s easier to create an object than add more properties by a new method.