NaN ("Not a Number") is hard to compare against. It never equals anything, not even itself:
NaN === NaN; // false Number.NaN === NaN; // false
There is the
isNaN method, but it is not really what you are looking for:
isNaN(NaN) // true isNaN('hello') // true
Object.is() method determines whether two values are the same value. It even works for
Object.is(NaN, NaN) // true
The example above shows that simply using
isNaN would match other objects, too. However, look at the weird type of "Not a Number":
typeof NaN // "number"
Hence we can actually check against
NaN like this:
var something = NaN; typeof something === 'number' && isNaN(something) // true
Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.