Skip to main content

JavaScript Principles

Thread of execution: The function of JS that can take the code and run it.

For a function to run, JS creates an Execution Context.

Initially we have a global Execution context, and for other functions JS creates a smaller one.

Execution context has a thread of execution and a memory that stores necessary data.

The placeholder we pass to a function definition as variable name is a parameter. The actual value we pass is called an argument.

JS keeps track of what function is currently running, using call stack.

When we run a function we add it to call stack, and now JS knows what is running.

As soon as the function hits ‘return’, the function’s execution thread evaporates.

At the bottom of this stack, there is a global( ) function which always is there.