The Relicans

Discussion on: My notes on Concepts of Modern JavaScript

Collapse
eduardoklosowski profile image
Eduardo Klosowski

One tip about arrow function, if use this without { ... }, the value of expression is automatic returned without need return statement, with { ... } around expression is necessary explicit return. Example:

const add1 = (a, b) => a + b;
console.log(add1(10, 5));  // print 15

const add2 = (a, b) => { return a + b; };
console.log(add2(10, 5)); // print 15

const add3 = (a, b) => { a + b; };
console.log(add3(10, 5));  // print undefined
Enter fullscreen mode Exit fullscreen mode