0
0
Javascriptprogramming~5 mins

Global execution context in Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the Global Execution Context in JavaScript?
It is the default environment where JavaScript code runs first. It creates a global object and sets up the 'this' keyword to refer to that global object.
Click to reveal answer
beginner
What two main phases happen inside the Global Execution Context?
1. Creation phase: JavaScript sets up memory for variables and functions.<br>2. Execution phase: JavaScript runs the code line by line.
Click to reveal answer
beginner
In the Global Execution Context, what does the 'this' keyword refer to?
It refers to the global object, which is 'window' in browsers and 'global' in Node.js.
Click to reveal answer
intermediate
What happens to variables declared with 'var' in the Global Execution Context during the creation phase?
They are hoisted and initialized with 'undefined' before the code runs.
Click to reveal answer
intermediate
How are functions treated differently from variables in the Global Execution Context creation phase?
Functions are hoisted and fully initialized, so they can be called before their declaration in the code.
Click to reveal answer
What is created first when JavaScript runs in the Global Execution Context?
ACreation of function expressions
BExecution of code line by line
CGlobal object and 'this' keyword setup
DCreation of local variables
During the creation phase, what value do 'var' variables get assigned?
Anull
Bundefined
C0
DNo value assigned
What does the 'this' keyword refer to in the Global Execution Context in a browser?
AThe global object (window)
BThe current function
Cundefined
DThe local scope
Which phase of the Global Execution Context runs the code line by line?
AInitialization phase
BCreation phase
CCompilation phase
DExecution phase
Can functions be called before they are declared in the Global Execution Context?
AYes, because functions are hoisted and fully initialized
BNo, functions must be declared first
COnly if declared with 'let'
DOnly if declared inside another function
Explain what happens during the creation phase of the Global Execution Context.
Think about what JavaScript prepares before running your code.
You got /4 concepts.
    Describe the role of the 'this' keyword in the Global Execution Context.
    Consider what 'this' points to when you are not inside any function.
    You got /4 concepts.