Hi everyone,

I just found something interesting in my code but I ain't sure why JavaScript.

var input= 0;  // But in my case, the input variable is getting the value from a field in a form


    document.write('it is not a ZERO');

This is something similar to my code.


4 Years
Discussion Span
Last Post by rotten69

the problem is the body of the if-statement gets executed which I don't want to happen.
I'm only checking if it is not a number then execute the if-statement body. Else, Go to the next condition.

Edited by rotten69


Literally, NaN stands for not a number.

NaN is a javascript object returned when a value treated as a number fails to convert to number. Basically it is not a number. Whereas the type of NaN it self, is - a number container that has no value. (It's not even a zero).

It's a box of numbers alright - but it's empty. Therefore (another) NaN is never equal to (previous/following) NaN, because it's a different box.

You cannot check if( Number("1.a") == NaN )
That's why isNaN() function was needed.

Though NaN==NaN >> is always false!
It's not a Voodoo..., since NaN is an Object;

It's the same as with other empty objects, say: []==[] >> false! They mey be equal in the sense of emptyness and type etc, alas, they are not the same "box". They are different instances of that type of objects.

Contrary to abstractions that can be equal, say 1==1 > true, -since all the 1's of the world are that same 1 (one). That is, the same abstraction. They (NaN's), will be compared by instances, not by values { as in say Number(1)==Number(1) >> true}, because there is a value of the same type that can be compared there. And since they belong to the same abstraction (1) they are the same. >> true!

There are a lot of highly "professional coders" that don't understand the half of it. And ask questions like: why is the typeof NaN >> "number" - this is a mistake! etc...
Yet, no other statement can be as far from the truth as this one is.

Edited by Troy III


Never worked out the abbreviation NaN. Thanks for the answer and the thread needs to be closed and solved.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.