JavaScript typeof null returns 'object'

⚡ Developer Brain Teaser – Only Experienced Developers Notice This What will be the output of this JavaScript code? 👇 console.log(typeof null); 🧠 Options A️⃣ "null" B️⃣ "object" C️⃣ "undefined" D️⃣ "number" 👇 Comment your answer before scrolling further. . . . ✅ Correct Answer: B️⃣ "object" 💡 Explanation In JavaScript: typeof null returns: "object" This is actually considered a historical bug in JavaScript that has existed since the first version of the language. Why? Internally, JavaScript represents values using type tags, and null was incorrectly tagged as an object. Because fixing it would break millions of existing applications, it has never been changed. 📌 Learning Point Even senior developers get surprised by JavaScript quirks. Understanding these edge cases helps during debugging, interviews, and writing reliable code. 💬 Did you know this already? Comment “Yes” or “Learned something new today” 👇 #JavaScript #FrontendDevelopment #Angular #CodingChallenge #Developers #TechLearning #SoftwareEngineering

To view or add a comment, sign in

Explore content categories