JavaScript · Junior · Question 4 of 75

How does let differ from var?

Explanation

A var declared inside an if or for is visible throughout the function. Also, var is hoisted with the value undefined and becomes a window property at the top level, while let and const are in the "temporal dead zone" until declared.

Further reading

Problem with a question

JavaScript · Junior · question 4

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz