Arrow Functions in JavaScript
Arrow functions ((a, b) => a + b) are compact function expressions with two defining traits: concise bodies (expression bodies return implicitly, no return keyword) and lexical this (inheriting this from the enclosing scope instead of rebinding). They dominate callbacks, array methods, and short utilities.
They are not universal replacements: arrows can't be constructors (new throws), have no arguments object (use rest), and lexical this backfires for object methods and event handlers needing dynamic receivers. Rule: arrows for callbacks and closures, function for methods and constructors.
Concise syntax
x => x * 2 (single param, expression body) through (a, b) => { ... } — braces mean statements plus explicit return.
Implicit return
Expression bodies return their value automatically; returning object literals needs parens: () => ({x: 1}).
Lexical this
Arrows capture this from definition scope — setTimeout callbacks and .then chains see the outer this correctly.
Know the limits
No new, no arguments, no own this — methods needing dynamic receivers and constructors stay function expressions.
let nums = [1, 2, 3];let doubled = nums.map(n => n * 2);console.log(doubled);Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in JavaScript yourself — building beats watching.