airbnb / airbnb/javascript

Discussion: Arrow Functions vs Traditional Functions

Offen
#3,121 20 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
question
Vorherrschende Sprache
JavaScript
Sterne
148k
Forks
26.6k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.