What is Infinity, -Infinity, and NaN Number Types in JavaScript? (EASY Explanation!)

There are 3 special types out there that are considered numbers but don’t actually behave as numbers.

Infinity and -Infinity in JavaScript

These are the positives and negatives of the concept of infinity.

They can both be considered the same since a negative infinity translates into the concept of infinity as well.

NaN in JavaScript

This is another special type that is also considered a number at the same time.

NaN stands for ‘Not a Number.’

Some examples of NaN include dividing Zero (0/0) by itself or subtracting Infinity (infinity – infinity) by itself.

Apparently, these numbers don’t have any meaning to them and as a result, JavaScript labels them as NaN.

Leave a Comment