DEV Community

loading...
Cover image for JavaScript Interview Question #16: typeof NaN

JavaScript Interview Question #16: typeof NaN

Coderslang: Become a Software Engineer
Teaching you to code at js.coderslang.com - JavaScript, HTML, CSS, Node.js, React.js, React Native
Originally published at learn.coderslang.com on ・1 min read

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.

Learn Full Stack JavaScript

Discussion (0)