Why typeof null === “object” in JavaScript

📰 Medium · Programming

Learn why typeof null returns 'object' in JavaScript and how to handle this quirk

intermediate Published 24 May 2026
Action Steps
  1. Read the article on Medium to understand the historical reason behind typeof null === 'object'
  2. Check the type of null in your JavaScript console to verify the behavior
  3. Use the === operator to check for null instead of relying on typeof
  4. Test your code with different input types to ensure robustness
  5. Apply this knowledge to fix or prevent bugs in your existing JavaScript projects
Who Needs to Know This

Developers and programmers working with JavaScript will benefit from understanding this concept to avoid potential bugs and errors in their code

Key Insight

💡 The typeof operator in JavaScript returns 'object' for null due to a historical reason, and using === is a better way to check for null

Share This
Did you know? typeof null === 'object' in JavaScript! Learn why and how to handle it

Key Takeaways

Learn why typeof null returns 'object' in JavaScript and how to handle this quirk

Full Article

And the interview question that sent me down a rabbit hole. Continue reading on Medium »
Read full article → ← Back to Reads