r/learnjavascript • • Jul 19 '21

JavaScript Function Facts

255 Upvotes

27 comments sorted by

View all comments

4

u/[deleted] Jul 20 '21

The first fact has an omitted exception: arrow functions. An arrow function without a return statement or curly braces will return the result of the evaluated inline statement.

For example:

const myFunc = (x) => x+2;
console.log(myFunc(1));
// 3