The DOM methods getElementById()
, nextSibling()
, childNodes[n]
, parentNode()
and so on return null
(defined but having no value) when the call does not return a node object.
The property is defined, but the object it refers to does not exist.
This is one of the few times you may not want to test for equality-
if(x!==undefined)
will be true for a null value
but if(x!= undefined)
will be true (only) for values that are not either undefined
or null
.