Back in my Java days, I learned to avoid NullPointerExceptions in conditions which should detect Null.
I did a lot like this:
if (myVariable.itsNull == Null) { ... }
In case of myVariable is Null Java throws an unwanted NullPointerException, even though I wanted to detect Null, but on a different position. The trick was to switch the conditions
if (Null == myVariable.itsNull) { ... }
Now myVariable can be Null without causing NPE's.
Then I entered the world of Ruby. By learning Ruby and CoffeeScript, it was the same, checking the const against the variable.
Now in JavaScript I stick to it, still doing if (1 == myVariable) { ... }.