airbnb / airbnb/javascript

Discussion: Arrow Functions vs Traditional Functions

Open
#3,121 20 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
148k
Forks
26.6k
PR merge metrics
No merged PRs in 30d

Description

The style guide recommends using arrow functions for anonymous functions (Section 8.1). While I agree with this recommendation, I think it would be helpful to add more examples showing when traditional functions might still be preferred, such as:

1. When you need the function to be hoisted
2. When you need to use `this` binding differently
3. When you need the `arguments` object

What do you think about adding these clarifications?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Section 8.1 of the JavaScript style guide and review the discussion for the requested clarifications. Done means the guide explains when traditional functions may be preferred for hoisting, `this` binding, and the `arguments` object, with examples for those cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.