Arrow Function
In one line
An arrow function is a compact function syntax using => that does not have its own this or arguments binding.
In simple words
Arrow functions (introduced in ES6) provide a shorter syntax for writing function expressions. They use the => arrow: (params) => expression or (params) => { statements }.
Two key differences from regular functions: (1) Arrow functions do not have their own this — they inherit this from the enclosing lexical scope. This makes them ideal for callbacks where you want to preserve the outer this. (2) Arrow functions do not have their own arguments object.
If the function body is a single expression, you can omit the curly braces and return — the expression is implicitly returned. For a single parameter, you can omit the parentheses: x => x * 2.
Example
const square = x => x * x;
const add = (a, b) => a + b;
const greet = (name = "Guest") => `Hello, ${name}`;
console.log(square(5)); // 25
console.log(add(2, 3)); // 5
console.log(greet()); // "Hello, Guest"Arrow functions with implicit return, default params, and concise syntax.
Common confusions
Confused with: regular function
The difference: Regular functions have their own this (determined by call); arrow functions inherit this from the enclosing scope. Regular functions can be constructors; arrow functions cannot.
Related terms
Related Resources
Related Lessons
- Functions
Learn about arrow functions.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.