← All topics
Quiz: Scope, Closures, Hoisting and this: questions with answers
15 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. What does this print? (code)
- Q2. What does this print? (code)
- Q3. What does this print? (code)
- Q4. What happens when you read a let variable before its declaration line in the same block?
- Q5. Why does a for (var i = 0; i < 3; i++) loop with setTimeout print 3 three times?
- Q6. Which kind of scope do let and const have, but var does not?
- Q7. In which direction does the scope chain look for a variable?
- Q8. For a normal (non-arrow) function, what decides the value of this?
- Q9. Why does an arrow function used inside a method see the method's this?
- Q10. What is a practical use of closures?
- Q11. What does this print? (code)
- Q12. What does this print? (code)
- Q13. What does this print? (code)
- Q14. What does this print? (code)
- Q15. Which change makes for (var i = 0; i < 3; i++) setTimeout(() = console.log(i)) print 0, 1, 2?