Null

Null means "no value". It can be thought of as a placeholder that JavaScript uses to say "there should be an value here, but there isn’t at the moment."

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
  

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