why typeof NaN is a 'number' ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why typeof NaN is a 'number' ?

console.log(typeof NaN); //number Why!! , NaN 'means Not a Number'.

22nd Feb 2017, 12:41 AM
Shakir Abdo
Shakir Abdo - avatar
1 Answer
+ 1
Well it's hard to explain but I will try: NaN is result of some calculation, that negate mathematical logic. For example 1/0 (1 divided by 0). It cannot be represented mathematicly (is this a word?), but for computer it's still a number, perhaps too complex to express, so programmers had an idea to make it easier for computer by introducing NaN. In shortcut: NaN is still a number, just too complex, or too big to express.
22nd Feb 2017, 3:18 AM
Jakub Stasiak
Jakub Stasiak - avatar