Skip to content

Commit cdc480a

Browse files
committed
minor
1 parent 7384c9a commit cdc480a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

1-js/05-data-types/05-array-methods/article.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ The value of `thisArg` parameter becomes `this` for `func`.
658658
For instance, here we use an object method as a filter and `thisArg` helps with that:
659659

660660
```js run
661-
let user = {
661+
let john = {
662662
age: 18,
663663
younger(otherUser) {
664664
return otherUser.age < this.age;
@@ -672,14 +672,14 @@ let users = [
672672
];
673673

674674
*!*
675-
// find all users younger than user
676-
let youngerUsers = users.filter(user.younger, user);
675+
// find all users younger than john
676+
let youngerUsers = users.filter(john.younger, john);
677677
*/!*
678678

679679
alert(youngerUsers.length); // 2
680680
```
681681

682-
In the call above, we use `user.younger` as a filter and also provide `user` as the context for it. If we didn't provide the context, `users.filter(user.younger)` would call `user.younger` as a standalone function, with `this=undefined`. That would mean an instant error.
682+
In the call above, we use `john.younger` as a filter and also provide `john` as the context for it. If we didn't provide the context, `users.filter(john.younger)` would call `john.younger` as a standalone function, with `this=undefined`. That would mean an instant error.
683683

684684
## Summary
685685

0 commit comments

Comments
 (0)