JavaScript · Middle · Question 59 of 75

What does typeof notDeclared return if notDeclared was never declared?

Explanation

typeof is the only operator safe on undeclared names, which is why typeof window !== "undefined" is used to detect the browser. It still throws for let/const in the TDZ.

Further reading

Problem with a question

JavaScript · Middle · question 59

Test yourself

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

Take this quiz