๐Ÿ“˜this

๐Ÿšง under construction

JS โŸฉ execution context โŸฉ lexical environment โŸฉ environment 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 have โ€œownโ€ this, itโ€™s taken from the "outer context" .

the body of a class has a this context.

๐Ÿ‘‰ see arrow function โŸฉ arrow 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