Image for post
Image for post

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.

Global Context

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.

Leo Miguel Javier Garcia

Front-end developer located in NYC.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store