Javascript - NaN and Infinity
Code Life
By Pierre Marsaa
What is NaN?
Sometimes in JavaScript, you'll try to do math that doesn't make sense. Instead of crashing your program, JavaScript gives you a special value: NaN.
NaN stands for Not a Number. It's what you get when a math operation fails or produces an undefined result.
↗️
Loading editor...
↶
↷
NaN is still a "number"?!
Yes, it's confusing! Even though NaN means "Not a Number", JavaScript considers it to be of type number. This is one of JavaScript's quirks you just have to remember.
Verify