The typeof NaN in JavaScript is number.
This is because NaN is a property of the Number object.
Example:
var num = Number("string value");
console.log(num); // returns NaN
console.log(typeof num); //returns 'number'
Background:
NaN stands for Not-a-number.
It is used to indicate that a value is not numeric.
Filed under: Front-end, JavaScript, JavaScript, js, NaN, Number, typeof
Pe langa “nan” vezi ca mai este este Infinity
I’d like to know using if conditional that a variable type is NaN
I mean, I could use “if (Number(str) == ‘NaN’)” to find it out?
Thanks
Hi Jim,
you can use following conditional that will yield true or false
isNaN(Number(“str”))