The last two types undefined and null represents no value. Let’s understand, what’s the difference between undefined and null value.
As compared to undefined, Null is an assignment value, it can be assigned to a variable in case of no value or empty value.
Let’s understand this concept using an example.
alert(first); // Prints undefined
alert(typeof first); // Prints undefined. It means undefined is type as well.
Now, Let’s initialize null to a variable.
var first = null;
alert(first); // Prints null
alert(typeof first); // Prints object, null is a type of object.
We have seen through example that undefined is a type itself whereas null is a special type of object.
For reference –