ES6 Recap
ES6 Recap
ES6 Recap
Use const and let instead of var
const and let instead of varUse the arrow function => to declare a function
=> to declare a functionconst addTwo = num => {
return num + 2;
}Use the arrow function => with implicit returns to declare a function that only returns something
=> with implicit returns to declare a function that only returns somethingconst addTwo = num => num + 2;Use the arrow function => preserves the original this context
=> preserves the original this contextfunction eatBreakfast(pancakes) {
var that = this;
that.food = 'Knife please?';
Waiter.bringCutlery(function (silverware) {
that.food = silverware;
});
}Use literals for assigning a variable as the value of the key of the same name
Use template literals for string interpolation
Last updated