Facebook Pixel

What is the difference between global and function execution context?

The global context is created once at program start and lives until the program ends. A function context is created every time a function is called and is destroyed when it returns.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Global Execution Context vs Function Execution Context

Exactly one per program. It sits at the bottom of the call stack for the entire lifetime of the script.

In a browser, this points to the window object. In Node.js modules, this points to module.exports (or globalThis in modern code).

No. Variables declared with var inside a function are local to that function's execution context and are not attached to window or globalThis.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

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.