Quote:
Originally Posted by Old Pedant
NOT TRUE AT ALL!
That may be true in PHP and JavaScript, but it is *NOT* true in some computer languages.
|
I should have said CAN HAVE rather than HAS. (Just about all the languages I know treat null as meaning something completely different from what it means in any other language).
Quote:
Originally Posted by Old Pedant
But stupid JavaScript, in these conditions, treats null the same as zero.
|
That's why you should always use === and !== in comparisons in JavaScript. Null in JavaScript is a placeholder for an object that has not yet been created and so two placeholders can be considered to have the same value hence null === null in JavaScript but comparing to anything else using the correct comparison operators will return false.
In JavaScript (null === 0) will return false because it does not treat them the same unless you are sloppy and use == which first tries to convert both values to the same type and both null and 0 can be converted to false giving false == false which is true..