Facebook Pixel
How JavaScript Creates Execution Context for Functions

How is this value set in a function execution context?

The answer

By how the function was called. A plain call gives this as undefined (strict mode) or the global object. A method call gives the object. call, apply, and bind set it explicitly. Arrow functions inherit this from their lexical scope.

More FAQs in How JavaScript Creates Execution Context for Functions

A new function execution context with a variable environment, an outer environment reference (for the scope chain), and a value for this. It is pushed onto the call stack.

A pointer to the parent function's environment. The engine follows these references up the chain to resolve variables not found locally. This is the scope chain.

When the function returns. Its call stack frame is popped and local variables are gone, unless a closure keeps a reference to the variable environment.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Your learning library

Small steps. Big possibilities.

Find your next course. Build something great.

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.