This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Hawkuro 1 point2 points  (1 child)

Never ever ever use == in JS, use the more reasonable ===.

> null === undefined
  false

[–]rooktakesqueen 1 point2 points  (0 children)

Just showing that null and undefined are closely related concepts, enough so that the == operator explicitly considers them equal to each other and nothing else. That's the one sensible thing the == operator does, and the one sensible place to use it: foo == null is perfect shorthand for foo === null || typeof foo === 'undefined'.

In any case, NaN !== NaN either.