Execution Context Flashcards
JavaScript code is evaluated as 1 of the following 3 environments.
- ) Global code
- ) Function code
- ) Eval code
When running a function in JavaScript we create a new …
Execution Context
Is there a limit to function execution contexts?
Technically no, depending on the host machine’s resources.
How many global execution contexts can there be?
Only ever one.
A new execution context creates a new …
Scope
The JavaScript interpreter in a browser is implemented as a … thread
single
How many things can happen at a time in a single-threaded environment?
One
What type of data structure is the Execution (call) Stack?
A LIFO (last in - first out) data structure
When a browser first loads a script, we enter the … context
Global execution context
What happens when a context has finished executing?
The context is popped off the stack and control returns to the context below it until the global context is reached again.
Name at least 3 key points about the execution stack.
- ) The execution stack is single-threaded
- ) The execution stack follows synchronous execution
- ) There is only ever 1 global context
- ) There are technically infinite function contexts
- ) Each function call creates a new execution context
There are 2 phases / stages to every call to an execution context. They are?
- ) Creation Stage
2. ) Activation / Code Execution Stage
What happens in the Creation Stage of a call to a new execution context?
- ) It creates a scope chain
- ) It creates an activation object (variables, functions, objects)
- ) It determines the value of ‘this’
What happens in the Activation Stage of a call to a new execution context?
Assign values, references to functions and interpret / execute code.
If an execution context was to be represented visually as an object, what would it look like?
It would have a scopeChain property, a variableObject property and a this property.
Each of these properties would have a value of an object.