1/0 === Infinity and 1/Infinity === 0

What is Infinity in JavaScript? ♾️

Infinity is indeed a value in JavaScript, representing mathematical infinity (∞). Be prepared for when it pops ups in your code.

Dr. Derek Austin 🥳
The Startup
Published in
7 min readNov 29, 2019

--

Photo by Jean-Philippe Delberghe on Unsplash

JavaScript: To Infinity And Beyond

Infinity is a property of the global object, or in other words, a variable in global scope.

The initial value of Infinity is Number.POSITIVE_INFINITY. The value Infinity (positive infinity) is greater than any other number. Mathematically, this value behaves the same as infinity; for example, any positive number multiplied by Infinity equals Infinity, and any number divided by Infinity equals 0.” — MDN Docs

The number Infinity is a special value in JavaScript that represents mathematical infinity and overflow values — numbers so large they “overflow” the buffer and result in Infinity.

It results from calculations creating numbers beyond a special maximum value in JavaScript, a value that is about 1.79e+308 or 2¹⁰²⁴— the largest value that can be stored as a number primitive type in JavaScript.

In this article, I explore the behavior of Infinity in JavaScript.

--

--

Dr. Derek Austin 🥳
The Startup

I write about real-world programming career advice, MongoDB vs. PostgreSQL, Git, React, JavaScript, VS Code, TypeScript, and Next.js. Doctor of Physical Therapy