Bitesize Bugs

typeof NaN in JavaScript

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.

Advertisements

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

So what’s it about?

Bitesize Bugs is a collection of short articles that expose pesky bugs in front-end web technologies like JavaScript, CSS, HTML and browser behaviors gone bad.