airbnb / airbnb/javascript

Discussion: Arrow Functions vs Traditional Functions

Aperta
#3,121 20 commenti 0 reazioni 0 assegnatari Vedi su GitHub
question
Lingua principale
JavaScript
Stelle
148k
Fork
26.6k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.