You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
686
+
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.
687
+
688
+
That said, a call `users.filter(user => army.canJoin(user))` also guarantees the correct `this`, and it's more obvious what's going on, so in practice the arrow function is used most of time, instead of `thisArg`.
0 commit comments