javascript-tutorial / javascript-tutorial/en.javascript.info
Incorrect information of Data Types/Array Methods about thisArg
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- HTML
- Star
- 25.5k
- Fork
- 4k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với bài viết Data Types/Array Methods và tìm ví dụ thisArg được nêu trong issue. Đối chiếu phần giải thích với hành vi của ví dụ, sau đó cập nhật cách diễn đạt để giải thích chính xác vấn đề và đánh giá xem có cần một phần rộng hơn về this hay không. Hoàn thành khi bài viết không còn quy lỗi cho nguyên nhân sai nữa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100