SyntaxStudy
Sign Up
JavaScript Beginner 4 min read

Arrow Functions

Arrow Functions

Arrow functions provide concise syntax and lexically bind this from the surrounding scope — no bind(this) needed.

Example
const add = (a, b) => a + b;
const double = n => n * 2;
const obj = () => ({ key: "value" }); // wrap in () to return object
const nums = [1, 2, 3].map(n => n * 2); // [2, 4, 6]
// Arrow keeps outer "this"
this.timer = setInterval(() => this.tick(), 1000);
Pro Tip

Do not use arrow functions as object methods — they inherit outer this, not the object.