JavaScript typeof null and undefined behavior

🤔 Quick JavaScript question  What do you think this logs? console.log(typeof null); console.log(typeof undefined); 👉 Output "object" "undefined" Surprising, right? 😄 🔹 null is meant to represent an intentional absence of value, but due to a legacy JavaScript bug, typeof null returns "object". 🔹 undefined means a variable exists but has not been assigned a value, and typeof undefined correctly reflects that. #JavaScript #WebDevelopment #NodeJS #MERN #LearningInPublic

To view or add a comment, sign in

Explore content categories