EasyType Coercion💻 Output Question

typeof for common values

💡

Hint

typeof null = "object" is a historic bug. Use Array.isArray() for arrays.

What does this output?

console.log(typeof null);
console.log(typeof undefined);
console.log(typeof []);
console.log(typeof function(){});

Correct Output

object
undefined
object
function

Why this output?

Explanation: typeof null = "object" is a famous JS bug. typeof [] = "object" (arrays are objects). Functions have their own typeof result.

Key Insight: typeof null = "object" is a historic bug. Use Array.isArray() for arrays.

More Type Coercion Output Questions

EasyPlus operator: string concat vs numeric addMediumLoose equality edge cases with nullMediumTruthy and falsy — empty array and object are truthyMediumUnary plus converts to number

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz