Skip to content
Related Articles

Related Articles

Improve Article

What is positive infinity in JavaScript?

  • Last Updated : 26 Sep, 2019
Geek Week

The positive infinity in Javascript is a number which is constant and represents a value which is highest available.It can be generated using a self made function or by an arithmetic operation.

Note: JavaScript shows the POSITIVE_INFINITY value as Infinity.

Positive Infinity is different from mathematical infinity in the following ways:

  1. The product of two positive infinity is positive infinity
  2. Product of positive and negative infinity is negative infinity
  3. If we divide any positive number by positive infinity, we will get positive 0
  4. If we divide any negative number by positive infinity, we will get negative 0
  5. 0 multiplied by positive infinity is NaN
  6. NaN multiplied by positive infinity is NaN
  7. We get negative infinity when we divide positive infinity by any negative number (except negative infinity)
  8. We get positive infinity when we divide positive infinity by any positive number (except positive infinity)
  9. Positive infinity divided by either positive or negative infinity is NaN



Example 1:

<!DOCTYPE html>
        h1 {
            color: green;
    <h1>What is positive infinity in JavaScript?</h1>
    <button onclick="geekPositiveInfinity()">
      Generate positive infinite
    <p id="geek"></p>
        function geekPositiveInfinity() {
           //positive value greater than the largest
           // representable number in JavaScript
            var n = (Number.MAX_VALUE) * 2;
            document.getElementById("geek").innerHTML = n;


Example 2:

function checkPositiveInfinity(x) {
  if (x === Number.POSITIVE_INFINITY) {
    return 'Number is Positive Infinity';
  return x;
console.log(checkPositiveInfinity(Number.MAX_VALUE * 2));


Supported Browsers:

  • Google Chrome
  • Mozilla Firefox
  • Apple Safari
  • Opera
  • Internet Explorer/Edge

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!

My Personal Notes arrow_drop_up
Recommended Articles
Page :