I can tell you that the first time someone showed me a similar example I just thought “WTF is going on here?”. There are other problems you’ll probably trip on when you start using NaN. For instance, I’ve seen code that looks like this in the past:

What will happen when you run the previous snippet? If you’re thinking you’ll be seeing an alert message with the text “oops2”, you’re wrong. The reason is simple: you cannot use the === operator to compare a value with NaN because NaN isn’t equal to itself. In other words, NaN === NaN will always return false and NaN !== NaN will always return true. Not cool, but that’s just the way it is.

Btw, the correct way to check for the NaN value is to use the isNaN helper function. Here’s the updated snippet that produces the expected results: