NULL
VS UNDEFINED
Undefined
means a variable has been declared but has not yet been assigned a value. On
the other hand, null is an assignment value. It can be assigned to a variable
as a representation of no value. Also, undefined and null both are two
different data types:
undefined
is a type itself (undefined)
null is
an object.
var a;//undefined
var b = null;
var c=5;
var d = a+c // NaN
var e = b+c //5
If I am trying to do any mathematical operation with null and number it gives me some number as output, instead of null if i am doing it with undefined and number the result is NaN
null !== 0;
undefined !==0;
Comments
Post a Comment