Arrow Functions
/* 90s */
function sayHi(userName) {
console.log('Hi ' + userName);
}
/* 2000s */
var sayHi = function (userName) {
console.log('Hi ' + userName);
};
/* 2015 */
const sayHi = (userName) => {
console.log('Hi ' + userName);
});No binding
class Customer {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
sayHi() {
console.log('Hi ' + this.firstName);
}
sayHiLater() {
setTimeout(() => {
this.sayHi();
}, 1000);
}
}Example with Array.filter and Array.map
Array.filter and Array.mapOne-liner
Last updated