javascript-tutorial / javascript-tutorial/en.javascript.info
Incorrect information of Data Types/Array Methods about thisArg
まだ誰も着手していません。
- 主要言語
- HTML
- スター
- 25.5k
- フォーク
- 4k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Data Types/Array Methods の記事から始め、issue に示されている thisArg の例を見つけてください。例の動作に照らして説明を確認し、そのうえで問題を正確に説明できるよう文言を更新し、this に関するより広いセクションが必要かどうかを評価してください。記事がエラーの原因を誤ったものとして説明しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100