Arrow Functions
JS · Functionssyntax
const fn = (params) => expression;
const fn = (params) => { ... };example
const double = n => n * 2;
console.log(double(7)); // 14
const greet = (name, greeting = "Hello") => `${greeting}, ${name}!`;
console.log(greet("Ava")); // "Hello, Ava!"
// Return an object literal (wrap in parentheses)
const makeUser = (name, id) => ({ name, id });
console.log(makeUser("Bo", 1));Note Arrow functions have no own this, arguments, or super. They inherit this from the surrounding scope, making them unsuitable as object methods or constructors.