Slide 18
Slide 18 text
React on ES6+ @nikgraf
Arrow Functions
// ES5
[2,2,3].map(function(item) {
return item + 1;
});
// Expression bodies
[2,2,3].map(item => item + 1);
// [3,3,4]
[2,2,3].map((item, index) => item + index);
// [2,3,5]
// Statement bodies
[2,2,3].forEach(item => {
if (item === 2) {
console.log('Found the number 2');
}
});