Undefined and null are both "non-value" values. They are similar, although they behave slightly differently. For example, if you try to do sums with them:
10 + null // null behaves like zero
<< 10
10 + undefined // undefined is not a number
<< NaN
<< 10
10 + undefined // undefined is not a number
<< NaN
null is coerced to be 0, making the sum possible whereas undefined is coerced to NaN, making the sum impossible to perform.
Values tend to be set to undefined by JavaScript, whereas values are usually set to null manually by the programmer.
0 Response to "Null"
Post a Comment