Skip to content
Related Articles

Related Articles

Improve Article
JavaScript Number Positive_INFINITY property
  • Last Updated : 08 Sep, 2020

Below is the example of the Number Positive_INFINITY property.

  • Example:




    <script>
    var a = Number.POSITIVE_INFINITY;
    document.write(a * 10);
    </script>
  • Output:
    Infinity

In javascript Number.POSITIVE_INFINITY represents the largest positive value i.e positive infinity. Actually value of Number.POSITIVE_INFINITY is the same as the value of the global object’s Infinity property.

Syntax:
It can be assigned to a variable in the following way.

var a = Number.POSITIVE_INFINITY

Now, we know what is Number.POSITIVE_INFINITY, let’s look at some examples to see the result of some arithmetic operations performed on Number.POSITIVE_INFINITY.

  • Example 1: When we multiply any positive number including Number.POSITIVE_INFINITY by Number.POSITIVE_INFINITY the result is Number.POSITIVE_INFINITY.




    <script>
    var a = Number.POSITIVE_INFINITY;
      
    document.write(a * 2);
    </script>

    Output:



    Infinity
  • Example 2: When we multiply any negative number with Number.POSITIVE_INFINITY the result is negative Infinity.




    <script>
    var a = Number.POSITIVE_INFINITY;
    document.write(a * -2);
    <script>

    Output:

    Infinity
  • Example 3: When we divide any positive or negative number by Number.POSITIVE_INFINITY the result is 0.




    <script>
    var a = Number.POSITIVE_INFINITY;
      
    document.write(2 / a);
    </script>

    Output:

    0
  • Example 4: When we multiply Number.POSITIVE_INFINITY by 0, result is NaN.




    <script>
    var a = Number.POSITIVE_INFINITY;
      
    document.write(a * 0);
    </script>

    Output:

    NaN
  • Example 5: When we divide Number.POSITIVE_INFINITY by any negative number except Number.NEGATIVE_INFINITY, result is Number.NEGATIVE_INFINITY.




    <script>
    var a = Number.POSITIVE_INFINITY;
      
    document.write(a / -2);
    </script>

    Output:

    Infinity
  • Example 6: When we divide Number.POSITIVE_INFINITY by any positive number except Number.POSITIVE_INFINITY, result is Number.POSITIVE_INFINITY.




    <script>
    var a = Number.POSITIVE_INFINITY;
      
    document.write(a / 2);
    </script>

    Output:

    Infinity
  • Example 7: When we divide Number.POSITIVE_INFINITY by either NEGATIVE_INFINITY or POSITIVE_INFINITY, result is NaN.




    <script>
    var a = Number.POSITIVE_INFINITY;
    var b = Number.NEGATIVE_INFINITY;
      
    document.write(a / b);
    </script>

    Output:

    NaN

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera



My Personal Notes arrow_drop_up
Recommended Articles
Page :