There seems to be a lot of confusion in the industry about how the
this
keyword works in Javascript. The purpose of this article is to share my exploration and some tests designed to reach a better understanding of this keyword mechanism.
In Javascript, this
is a context-sensitive keyword. It means its reference can change depending on how you execute a given function. By default, the this
keyboard is bound to the object that’s executing the function.
In a browser environment the window object and the this
keyword are equivalent.
Front-end developer located in NYC.