← BYTES
JavaScript·Intermediate·Ref: 3.2.3

In a regular (non-arrow) function, what determines the value of `this`?

Have a question about this video? Mention reference 3.2.3 when you contact us.

a.`this` is always the global object, with no exceptions
b.`this` always refers to the function itself
c.It depends on how the function is CALLED (as a method, standalone, via call/apply/bind, etc.), not where it's defined
d.`this` is determined at the time the function is defined, exactly like an arrow function
A regular function's `this` is determined dynamically by its call-site -- calling obj.method() binds this to obj, calling the same function standalone loses that binding, and call/apply/bind can set it explicitly. This is the opposite of arrow functions, which capture this lexically from their enclosing scope at definition time, regardless of how they're later called.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES323#JavaScript