📘this

🚧 under construction

JSexecution contextlexical environmentenvironment record ⟩ "this"

(primary expression)

Within the body of a method, "this" evaluates to the object on which the method was invoked.

this

The value of this in a normal function is by default:

arrow functions don’t haveownthis, it’s taken from the "outer context" .

the body of a class has a this context.

👉 see arrow functionarrow function as class field❗️.

if the code you need to wrap a scope around has return, this, break, or continue in it, don't use a function/IIFE(which has its own function boundary), use a block instead❗️

📗 You Don't Know JS Yet: Scopes & Closrues

the value of this is stored in environment record.

Last updated