Which seemed to make sense because, since we don’t want to perform any type coercion on the null object, this should be faster.
However, when I reloaded the page, the comparison (previously returning true) was now returning false. Confused, I fired up the web inspector to discover this:
Undefined and null
The many meanings of undefined
So, you can just do this:
The problem is, somewhere in your code or in a library, someone else could overwrite the undefined variable to be a string:
It’s worth noting that ECMA 5 forbids setting the value of undefined, but currently, only Safari enforces this.
Comparing the types