Back to questions
JuniorTheoryCommon
What does the program print?
console.log(typeof null, typeof undefined, typeof NaN);object undefined number
- Expecting
nullfortypeof null: it gives"object". This is an old mistake in JavaScript that was never fixed, so it has to be remembered. - Expecting
NaNto have its own type:NaNmeans “not a number”, yet it is a value of typenumber, sotypeof NaNis"number".
- What does
typeof typeof 1print, and why? - How would you check that a variable holds
null, given whattypeofreturns?