bind method. I wanted to discuss in detail how
bind makes it possible to have interesting and readable object-oriented code, while at the same time embracing event handlers and
setTimeout to control your code’s execution. The issue is simply that event handlers execute your code in a context outside your objects, which makes the
this keyword confusing at best, and flat-out wrong at worst.
bind is an elegant solution to the problem, and the article concludes with a deep dive into a simplified version of that function to tease out exactly what it does, and how it works.
I found, however, that the article was mostly incomprehensible to those without a firm grounding in the issues of scope and execution context, and the lesser-known ways of manipulating execution context (
call). In an effort to give that audience something to sink their teeth into, I added a good amount of discussion of the basic concepts of scope, and what an execution context really means. I hope I’ve struck a good balance between the two, and that the article builds a solid foundation as it goes.