Why Arrow Functions Were Introduced

Arrow functions were not introduced to replace regular functions β they were added to solve specific problems that arose with this
and function expressions in functional-style programming and callbacks.
π Key Reasons for Arrow Functions
1. β
Lexical this
binding
In many cases, especially with event handlers, callbacks, or setTimeout, regular functions caused problems with this
.
π§± Problem with this
in regular functions:
function Timer() {
this.seconds = 0;
setInterval(function () {
this.seconds++;
console.log(this.seconds); // β NaN or undefined
}, 1000);
}
- Here,
this
insidesetInterval
refers to thewindow
object, not theTimer
instance.
β Arrow functions fix this:
function Timer() {
this.seconds = 0;
setInterval(() => {
this.seconds++;
console.log(this.seconds); // β
Works as expected
}, 1000);
}
- Arrow functions capture
this
from the surrounding context (lexical scoping), solving a long-standing headache.
2. β Shorter syntax for inline functions
Functional programming patterns use a lot of small functions like:
const doubled = arr.map(function(n) {
return n * 2;
});
With arrow functions:
const doubled = arr.map(n => n * 2);
Itβs more concise, especially for one-liners.
3. β Better for callbacks / promises
In chaining or async code, they reduce clutter:
fetch('/api')
.then(res => res.json())
.then(data => console.log(data));
This would be unnecessarily verbose with traditional functions.
π« The Downsides
Arrow functions:
β Can make
this
confusing when used inside objects.β Reduce readability for beginners.
β Are not suitable for object methods.
β Have no
arguments
object, which sometimes matters.
π§ Summary
Feature | Arrow Function | Regular Function |
this binding | Lexical (from context) | Dynamic (based on caller) |
Short syntax | β Yes | β No |
Use as object method | β No (avoid) | β Yes |
Use in callbacks/promises | β Recommended | β Also fine, but wordier |
Has arguments object | β No | β Yes |
π¬ Final Thought
Arrow functions should not be used blindly.
Use them:
For callbacks, short functions, and functional programming patterns.
Avoid them for object methods where you rely on
this
.
In short: arrow functions are a tool, not a replacement.
Subscribe to my newsletter
Read articles from Taher Maimoon directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
