Top 10 Javascript ES6 things A Js Developer Must Know
1. Default Parameters
In ES6, we can put the default values right in the signature of the functions.
var area = function(height = 100, width = 80) {
...
...
}
2. Template Literals
In ES6, we can use a new syntax ${parameter}
inside of the back-ticked string. You have to write the whole thing in `` sign.
and dynamic parameter should deploy in ${param}.
var myName= `My name is ${firstName} ${lastName}.`
3. Destructuring
The destructuring assignment syntax is a JavaScript expression that makes it possible to destructure values from specific arrays, or properties from objects, into different variables.
var myDetails= {name: 'Anis', address: 'BD'};
var {name, address} = myDetails;console.log(name); // Anis
console.log(address); // BD
4. Modules
In ES6, there are modules with import
and export
operands.
Let this code is placed in the “module” file. ES6 permitted that programmer can export any part from any file by “export” keyword.
export const id = 1;
export function myName(name) {
//code
};
It is possible to import idvariable and myName function using import statement.
import {id, myName} from 'module';
console.log(id); // 1