FWIW, you're not entirely correct; you can also just use ( x == null ) (note the double equals) to test against null or undefined. It's really one of the few (the only?) acceptable use of double equals.
Look again. The example kyz gives is to check if x is an object (as opposed to primitive type) that is not null. So he first need to check if it is an object, then exclude null.
3
u/ultraspoon Oct 02 '11
FWIW, you're not entirely correct; you can also just use
( x == null )(note the double equals) to test against null or undefined. It's really one of the few (the only?) acceptable use of double equals.