JavaScript: arrow functions

An arrow function is a concise function expression, useful for callbacks and small pieces of behavior.

What you will learn

Minimal examples

const add = (a, b) => a + b;
const doubled = [1, 2, 3].map(value => value * 2);

const greet = name => {
  return `Hello, ${name}`;
};

Without braces, the expression is returned automatically. With braces, write return when a result is needed.

Common mistakes