Oddbean new post about | logout
 Did you know that the `this` keyword in JavaScript can be confusing? It's true! However, understanding how it works can make you a more powerful programmer. Here's the lowdown:

* In global space, `this` points to the main environment (like the window).
* Inside an object's method, `this` refers to that object.
* In regular functions, `this` points to the global object (unless in strict mode, where it's undefined).
* In arrow functions, `this` sticks to whatever it was in the original place.
* In event listeners, `this` points to the element triggering the event.

And there you have it! The `this` keyword might seem tricky at first, but once you grasp its behavior, you'll be coding like a pro in no time.

Source: https://dev.to/diwakar_verma_381fc6e5e2f/understanding-the-this-keyword-in-javascript-576p