← Quiz: Scope, Closures, Hoisting and this: all 15 questions
Quiz: Scope, Closures, Hoisting and this · Question 4 of 15
What happens when you read a let variable before its declaration line in the same block?
What happens when you read a let variable before its declaration line in the same block?
- A.You get undefined
- B.You get null
- C.A ReferenceError, because the variable is in the temporal dead zone
- D.JavaScript moves the value up automatically
Answer & explanation
Correct answer: A ReferenceError, because the variable is in the temporal dead zone
let and const are hoisted but cannot be accessed until their declaration runs.
Can you get the rest right without peeking?
Take the timed Quiz: Scope, Closures, Hoisting and this quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →