Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Incorrect information of Data Types/Array Methods about thisArg

Aperta
#3,766 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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:
Example code

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di javascript-tutorial/en.javascript.info

Tutte le issue di javascript-tutorial/en.javascript.info

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.