What is the purpose of the Temporal Dead Zone (TDZ) in JavaScript?
A). A. To prevent variable reassignment
B). B. To catch errors at compile time
C). C. To ensure variables are initialized before use
D). D. To reduce memory usage
How does hoisting affect variable shadowing in JavaScript?
A). A. It allows variables with the same name in different scopes to coexist
B). B. It prevents variables with the same name in different scopes from coexisting
C). C. It has no effect on variable shadowing
D). D. It automatically renames variables with the same name
Which keyword allows hoisting of variables in JavaScript?
A). A. var
B). B. let
C). C. const
D). D. Both A and B
How can you avoid issues related to hoisting and TDZ in JavaScript?
A). A. Always declare variables at the bottom of the code
B). B. Use var for all variable declarations
C). C. Declare variables with let or const and avoid accessing them early
D). D. None of the above
What is the result of the following code snippet?
A). A. SyntaxError
B). B. ReferenceError
C). C. TypeError
D). D. No error
Which of the following is true about const variables in JavaScript?
A). A. They can be reassigned after declaration
B). B. They can be accessed before declaration
C). C. They cannot be declared without an initial value
D). D. They cannot be hoisted
What is the behavior of accessing a const variable within a function before its declaration in JavaScript?
A). A. ReferenceError is thrown
B). B. SyntaxError is thrown
C). C. undefined is printed
D). D. No error
What is hoisting in JavaScript?
A). A. A process of lifting heavy objects
B). B. Moving variable and function declarations to the top of their scope
C). C. Reducing code size
D). D. None of the above
What is the behavior of accessing a const variable before its declaration in a nested block in JavaScript?
A). A. ReferenceError is thrown
B). B. SyntaxError is thrown
C). C. undefined is printed
D). D. No error
How does hoisting differ between let and var declarations in JavaScript?
A). A. Both let and var variables are hoisted with their initial values
B). B. let variables are hoisted with their initial values, var variables are hoisted with undefined
C). C. let variables are not hoisted, var variables are hoisted with their initial values
D). D. Hoisting behavior is the same for let and var declarations