Skip to main content

Difference between null and undefined.

Entry JavaScript
Quick Answer null is an intentional absence of value รขโ‚ฌโ€ you explicitly set it. undefined means a variable was declared but not yet assigned, or a function returns nothing, or an object property doesn't exist. typeof null is "object" (a famous JS bug). typeof undefined is "undefined". Both are falsy.

Answer

null: explicitly assigned to indicate no value.

undefined: declared but not assigned.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice