Incorrect information of Data Types/Array Methods about thisArg
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Documentation
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- javascript
- Domaine
- documentation
Piste de recherche
Commencez par l’article Data Types/Array Methods et repérez l’exemple de thisArg présenté dans l’issue. Vérifiez l’explication par rapport au comportement de l’exemple, puis mettez à jour la formulation pour expliquer correctement le problème et évaluez si une section plus générale sur this est nécessaire. C’est terminé lorsque l’article n’attribue plus l’erreur à la mauvaise cause.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- HTML
- Étoiles
- 25.5k
- Forks
- 4k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de javascript-tutorial/en.javascript.info
-
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
-
Keyboard events: keydown filtering example can't block IME-composed input (Korean/Japanese/Chinese) Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
javascript-tutorial/en.javascript.info#3978 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Toutes les issues de javascript-tutorial/en.javascript.info
Issues similaires
-
triage
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
feature pydanty:is-working
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
pydantic/pydantic-ai#8647 ·
-
Add date o "release information" Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Add more to the documentation Ouverte:watch: Not Triaged dotnet-fsharp/svc
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100