In JavaScript, there are seven primitives: String, Number, Boolean, Null, Undefined, Symbol and BigInt. And now it focuses on Null and Undefined.
Undefined
- Indicates the absence of a value.
- A variable declared but not assigned anything is called
undefined
.
- A function that returns nothing result in
undefined
.
Null
- Represents “nothingness”
- Developers explicitly set a value to
null
.
Difference
null
andundefined
are different.null === undefined
results infalse
.
Summary
Undefined
means no value assigned, while Null
represents intentional nothingness. They are distinct primitives
in JavaScript.