PRACTICE • LEARN • GROW
Module 5 Final Quiz: Scope & Execution MCQs
Solve topic-wise placement questions and improve your skills.
Module 5 Final Quiz: Scope & Execution Progress
0 of 12 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What does lexical scoping mean in JavaScript?
A.
Variables are scoped dynamically depending on the caller stack trace
B.
Variable accessibility is strictly determined by physical nesting in source code at author time
C.
All variables have global scope across files
D.
Scope is determined only after JIT compilation
Explanation & Key
Correct Answer:
2
What will be printed by this scope resolution code?
let x = 'global';
function outer() {
let x = 'outer';
function inner() {
console.log(x);
}
inner();
}
outer();
A.
'global'
B.
'outer'
C.
undefined
D.
ReferenceError
Explanation & Key
Correct Answer:
3
What is an Execution Context in the JavaScript engine?
A.
A CSS layout context
B.
The internal environment created by the engine to manage variable environments, scope chains, and 'this' during code execution
C.
A DOM container element
D.
A thread pool manager
Explanation & Key
Correct Answer:
4
What are the two primary phases of an Execution Context lifecycle?
A.
Parsing phase and Linking phase
B.
Creation Phase (Memory Allocation) and Execution Phase (Code Evaluation)
C.
Compilation Phase and Garbage Collection Phase
D.
Synchronous Phase and Asynchronous Phase
Explanation & Key
Correct Answer:
5
What is the Temporal Dead Zone (TDZ)?
A.
The time spent waiting for a network response
B.
The time interval between the start of a scope and the line where a let or const variable is physically declared
C.
The duration before a timer expires
D.
The time during garbage collection sweeps
Explanation & Key
Correct Answer:
6
What will happen in this block scope snippet?
if (true) {
var a = 1;
let b = 2;
}
console.log(a, typeof b);
A.
1 'undefined'
B.
1 'number'
C.
ReferenceError
D.
undefined 'undefined'
Explanation & Key
Correct Answer:
7
What is variable shadowing in JavaScript?
A.
A variable hidden by private class syntax
B.
An inner scope variable having the same identifier as an outer scope variable, masking the outer variable within that inner scope
C.
Deleting a variable using the delete keyword
D.
A variable in the Temporal Dead Zone
Explanation & Key
Correct Answer:
8
What is the output of the following function parameter TDZ snippet?
function test(a = b, b = 2) {
return a + b;
}
test();
A.
4
B.
NaN
C.
ReferenceError: Cannot access 'b' before initialization
D.
undefined
Explanation & Key
Correct Answer:
9
Which execution context is created first when a JavaScript script starts executing?
A.
Function Execution Context
B.
Global Execution Context (GEC)
C.
Eval Execution Context
D.
Module Execution Context
Explanation & Key
Correct Answer:
10
Why does the following code throw an error?
let x = 10;
function foo() {
console.log(x);
let x = 20;
}
foo();
A.
Because x cannot be reassigned
B.
Because let x in foo() is hoisted to the top of foo's scope, creating a TDZ that shadows outer x before its declaration line
C.
Because inner functions cannot access outer variables
D.
Because foo is not a pure function
Explanation & Key
Correct Answer:
11
In browser environments, which object does the Global Execution Context bind to 'this' in non-strict mode?
A.
document
B.
window
C.
global
D.
null
Explanation & Key
Correct Answer:
12
What happens if a variable is assigned without any declaration keyword (e.g.
x = 5;) in non-strict mode?
A.
It creates a block-scoped variable
B.
It accidentally creates an accidental global property on the window object
C.
It throws a syntax error immediately
D.
It enters the Temporal Dead Zone
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong