Arrow functions are shorter, but the real differences are in binding behavior, not just syntax.
const regular = function () {};
const arrow = () => {};
const short = x => x * 2; // implicit return for one expression
Arrow functions are shorter, but the real differences are in binding behavior, not just syntax.
const regular = function () {};
const arrow = () => {};
const short = x => x * 2; // implicit return for one expression
1. No own this — arrows inherit this from the enclosing scope. This is the most important difference and why they're great for callbacks:
const timer = {
seconds: 0,
start() {
setInterval(() => this.seconds++, 1000); // ✅ `this` is timer
// a regular function here would have its own `this` (undefined) → bug
},
};
2. No arguments object — use rest parameters instead:
const sum = (...args) => args.reduce((a, b) => a + b, 0);
3. Cannot be used as constructors — new arrow() throws, and they have no prototype.
const obj = {
name: "Ann",
greet: () => `Hi ${this.name}`, // ❌ `this` is NOT obj (it's outer scope)
greet2() { return `Hi ${this.name}`; }, // ✅ method needs dynamic `this`
};
Don't use arrows for object methods (they won't bind to the object) or when you need a dynamic this/arguments (event handlers that rely on this being the element).
Use arrows for callbacks and short functions where inheriting this is what you want; use regular functions for methods, constructors, and prototype methods.
A library of IT interview questions with detailed answers — from Junior to Senior.
Donate