joseph joseph - 1 year ago 68
Javascript Question

Is NaN equal to NaN?


returns "NaN", but

parseFloat("NaN") == "NaN"

returns false. Now, that's probably a good thing that it does return false, but I don't understand how this is so. Did the JavaScript creators just make this a special case? Because otherwise I can't understand how this returns false.

Answer Source

When a JavaScript function returns NaN, this is not a literal string but an object property in the global space. You cannot compare it to the string "NaN".


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download