Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I can not understand what is the main difference between null and undefined.
console.log(a)
a
typeof a === "undefined"
const a = null
typeof a === "object"
Null: It is the intentional absence of the value. It is one of the primitive values of JavaScript.
Undefined: It means the value does not exist in the compiler. It is a global object.
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
console.log(a):ais undefined. It doesn't exist at all.typeof a === "undefined". But if you doconst a = null, thenais defined. Its value is a null object, but it is defined and exists.typeof a === "object".