Most of the JS developers out there might have come across one of JavaScript’s most confusing topic: THIS

So, who the hell is **this**? 🤔

Technically, JavaScript this refers to the object that the function belongs to. And the value of this depends on how the function is called, something known as runtime binding.

In layman’s terms, **this** points to the owner of the function call, I repeat, the function call, and NOT the function itself. The same function can have different owners in different scenarios.

4 rules decide the value of **this**

1. Default binding | Direct invocation

**this** in Default Binding points to the global object. Default binding is applied for standalone functions and is the fallback option for all other types.

2. Implicit binding | Method invocation

Implicit Binding is applied when you invoke a function in an Object using the dot notation. **this** in such scenarios will point to the object using which the function was invoked. Or simply the object on the left side of the dot.

#arrow-functions #es6 #javascript

Javascript ‘This’. Who Is This?
1.15 GEEK