Incorrect information of Data Types/Array Methods about thisArg
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- documentation
Direzione di ricerca
Inizia con l'articolo Data Types/Array Methods e individua l'esempio di thisArg mostrato nell'issue. Verifica la spiegazione rispetto al comportamento dell'esempio, quindi aggiorna la formulazione per spiegare accuratamente il problema e valuta se sia necessaria una sezione più ampia su this. Il lavoro è completato quando l'articolo non attribuisce più l'errore alla causa sbagliata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I was reading the article on Data Types, Array Methods when I saw the example code for thisArg. The example code below:
The explanation why the code would give a problem if we omit the thisArg argument here is:
If in the example above we used users.filter(army.canJoin), then army.canJoin would be called as a standalone function, with this=undefined, thus leading to an instant error.
The canJoin isn't called as a standalone function. It's been called in the context of army with the dot syntax. Inside canJoin where we use the 'this' keyword, 'this' points correctly to army. The problem here for some reason is the (implicit in that case as we haven't define it) is the user member of the users array. That's what causes the error and not the omission of the thisArg.
I believe that a whole section about how 'this' works would be highly valuable as it's extremely important to know and often a source of bugs.
- Lingua principale
- HTML
- Stelle
- 25.5k
- Fork
- 4k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di javascript-tutorial/en.javascript.info
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
Keyboard events: keydown filtering example can't block IME-composed input (Korean/Japanese/Chinese) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
javascript-tutorial/en.javascript.info#3978 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Tutte le issue di javascript-tutorial/en.javascript.info
Issue simili
-
triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
feature pydanty:is-working
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
pydantic/pydantic-ai#8647 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
:watch: Not Triaged dotnet-fsharp/svc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100