JavaScript

How does `this` work in JavaScript?

Medium
4
Added
Determined by how a function is called (execution context).

Solution Code

JavaScript
const obj = { logThis: () => console.log(this) };
Explanation
In regular functions, this depends on invocation context. Arrow functions use lexical this.

Guided Hints

Different binding rules
How bind/call/apply affect this