Bitesize Bugs

typeof NaN in JavaScript

The typeof NaN in JavaScript is number.
This is because NaN is a property of the Number object.


var num = Number("string value");
console.log(num); // returns NaN
console.log(typeof num); //returns 'number'


NaN stands for Not-a-number.
It is used to indicate that a value is not numeric.


Filed under: Front-end, JavaScript, , , , ,

3 Responses

  1. Alex says:

    Pe langa “nan” vezi ca mai este este Infinity

  2. Jim says:

    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?


  3. bitesizebugs says:

    Hi Jim,

    you can use following conditional that will yield true or false


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: