Skip to content

OutputNot attempted

typeof quirks

console.log(typeof null, typeof [], typeof NaN, typeof function () {}, typeof class {}, typeof typeof 1);

Spaces and quote style don’t matter · write a thrown error as TypeError

Ctrl Enter
Show answer & explanation

The expected output comes from actually running the snippet; opening this shows it next to the explanation.

typeof null is "object" (a historic bug). Arrays are objects; use Array.isArray. NaN is a number. Classes are functions. typeof always returns a string.