I want to know what the difference is between null
and undefined
in JavaScript.
The difference between undefined
and null
is minimal, but there is a difference. A variable whose value is undefined
has never been initialized. A variable whose value is null
was explicitly given a value of null
, which means that the variable was explicitly set to have no value. If you compare undefined
and null
by using the null==undefined
expression, they will be equal.