April 2018
Intermediate to advanced
284 pages
5h 46m
English
| Tip 42 | Resolve Context Problems with Bind() |
In this tip, you’ll learn how to solve this errors with bind().
In Tip 36, Prevent Context Confusion with Arrow Functions , you saw how functions create a new context and how a new context can give you results you aren’t expecting. Changing context can create confusion, particularly when you’re using the this keyword in callbacks or array methods.
Sadly, the problem doesn’t go away in classes. Earlier, you learned how you can use arrow functions to create another function without a new context. In this tip, you’ll learn more techniques for preventing context problems. The techniques you’re about to learn work on object literals and classes, but they’re much more common in class syntax, particularly ...
Read now
Unlock full access