Arrow functions (=>) are concise. They lexically bind this from surrounding scope—important for callbacks.
Syntax
const double = n => n * 2; — omit braces for single-expression returns.
this binding
Do not use arrows as object methods if you need dynamic this—use regular functions or class methods.
Important interview questions and answers
- Q: Arrow as method?
A: Often wrong—this stays lexical parent, not the object. - Q: Implicit return?
A: Expression body returns value; block body needs explicit return.
Self-check
- Why arrows in array callbacks?
- When not use arrow for methods?
Tip: Re-run the playground code for arrow-functions and tweak one line before the MCQs.
Interview prep
- Arrow this?
Lexical—inherits enclosing this.