ES6 Specific Features
For
for (variable of iterable) {
statement
}Spread
expand an array to serve as args/eles for another ft
function myFunction(x, y, z) { }
var args = [0, 1, 2];
myFunction.apply(null, args);
//becomes
function myFunction(x, y, z) { }
var args = [0, 1, 2];
myFunction(...args);Other uses
var arr2 = [...arr]; // like arr.slice()
<Component {...this.props} more="values" /> //React
var parts = ['shoulders', 'knees'];
var lyrics = ['head', ...parts, 'and', 'toes'];
var obj1 = { foo: 'bar', x: 42 };
var obj2 = { foo: 'baz', y: 13 };
var clonedObj = { ...obj1 };
// Object { foo: "bar", x: 42 }
var mergedObj = { ...obj1, ...obj2 };
// Object { foo: "baz", x: 42, y: 13 }Destructuring
Computed Property Names
More complex example
Arrow functions
Preserves this function
Template Literals
Tag Functions
EMCA 2020
Optional Chaining
For use when you are accessing an object deeply and arent sure about key existence
Nullish Coalescing Operator
Last updated