- Just finished the first ‘Sticky’ point or most confusing/tricky instances where this won’t operate as might be expected. And I actually understood it completely, which is a testament to the article because other tutorials/resources really weren’t as helpful.
- My main takeaway right now is that this inside a function called as a method to an object will refer to the object. The problem in passing that object.method as an argument in another function or object.method is that this will refer to the new object that is ultimately invoking the function holding this. But you fix this by binding the old/previous object to this using the .bind() method on the object.method that currently holds this. So instead of newObject.method(oldObject.method), you write newObject.method(oldObject.method.bind(oldObject)).