null is used to indicate that a variable does not have a value.
This example shows the difference between null and undefined.
var foo; // undefined, there is no value assigned var bar = null; // null, states that there is no value
null is the only value of the Null type
null vs. undefined
null can be assigned to a variable to represent no value.
undefined means a value is declared but not initialized, it doesn’t have a value assigned to it.
Other than that, null is an object, while undefined is a type.