js-test-16

What’s the type of Not a Number?

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

In JavaScript, NaN means Not a Number. This is a special value that appears whenever JS can’t make sense of the numerical expression.

NaN also often appears during typecast. For example, if you try to convert the string into a number, the result will be NaN.

It may seem counterintuitive, but NaN is just a special number. Thus its type is considered to be number.

You can tackle this problem from a different angle and try to answer the question:

What else typeof NaN can be?


ANSWER: the typeof NaN is number, which will be logged to the console.