Open In App

JavaScript Number Positive_INFINITY Property

Improve
Improve
Like Article
Like
Save
Share
Report

In javascript Number.POSITIVE_INFINITY represents the largest positive value i.e positive infinity. Actually the 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.

let a = Number.POSITIVE_INFINITY

Return value: It returns the number Infinity

Below are examples of the Number Positive_INFINITY property.

Example 1: In this example, we will print Infinity on the console.

javascript




let a = Number.POSITIVE_INFINITY;
console.log(a * 10);


Output:

Infinity

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

javascript




let a = Number.POSITIVE_INFINITY;
 
console.log(a * 2);


Output:

Infinity

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

javascript




let a = Number.POSITIVE_INFINITY;
console.log(a * -2);


Output:

-Infinity

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

javascript




let a = Number.POSITIVE_INFINITY;
 
console.log(2 / a);


Output:

0

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

javascript




let a = Number.POSITIVE_INFINITY;
 
console.log(a * 0);


Output:

NaN

Example 6: When we divide Number.POSITIVE_INFINITY by any negative number except Number.NEGATIVE_INFINITY, the result is Number.NEGATIVE_INFINITY. 

javascript




let a = Number.POSITIVE_INFINITY;
 
console.log(a / -2);


Output:

-Infinity

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

javascript




let a = Number.POSITIVE_INFINITY;
 
console.log(a / 2);


Output:

Infinity

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

javascript




let a = Number.POSITIVE_INFINITY;
let b = Number.NEGATIVE_INFINITY;
 
console.log(a / b);


Output:

NaN

Supported Browsers:

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

We have a Cheat Sheet on Javascript Numbers where we covered all the important topics of Javascript to check those please go through JavaScript Number Complete Reference.



Last Updated : 02 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads