Beginner JavaScript Interview QuestionsBeginnerComparison
JavaScript · Question 15
How are arrow functions different from regular functions in JavaScript?
Direct answer
Arrow functions use shorter syntax and capture this lexically; unlike regular functions, they do not have their own this, arguments, or constructor behavior.
Arrow functions are useful for concise callbacks, for example const double = n => n * 2;. Their biggest semantic difference is that they do not create their own this binding.
- Arrow functions capture this from the surrounding lexical scope.
- They do not have their own arguments object; rest parameters are usually preferred when arguments are needed.
- They cannot be called with new as constructors.
- Regular functions are usually better when a method needs dynamic this based on how it is called.