DEV Community

Cover image for JavaScript Interview Question #16: typeof NaN
Coderslang: Become a Software Engineer
Coderslang: Become a Software Engineer

Posted on • Originally published at learn.coderslang.com on

6 1

JavaScript Interview Question #16: typeof NaN

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

Top comments (0)

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay