Your product could be here, in front of thousands of JavaScript developers. Sponsor this spot →
JavaScript Quiz

JavaScript typeof and Types Quiz

JavaScript has seven primitive types plus objects, and two operators for checking types: typeof and instanceof. Both have quirks. typeof always returns a string, even for NaN, and instanceof returns false for primitives because they’re not objects.

Knowing how types really work makes debugging easier and helps you write reliable type checks.

Types & typeof questions

  1. Why is typeof NaN "number" in JavaScript?
  2. Why is "a string" instanceof String false?
  3. What does typeof typeof 1 return?
  4. Why is typeof null "object" in JavaScript?
  5. Is null equal to undefined in JavaScript?
  6. Why doesn't typeof throw for undeclared variables?
  7. What is typeof a class in JavaScript?

More topics