What is negative infinity in JavaScript?

30 Aug, 2019
The negative infinity in JavaScript is a constant value which is used to represent a value which is the lowest available. This means that no other number is lesser than this value. It can be generated using a self-made function or by an arithmetic operation.
Note: JavaScript shows the NEGATIVE_INFINITY value as -Infinity.
Negative infinity is different from mathematical infinity in the following ways:
Negative infinity results in 0 when divided by any other number.When divided by itself or positive infinity, negative infinity return NaNNegative infinity, when divided by any positive number (apart from positive infinity) is negative infinity.Negative infinity, divided by any negative number (apart from negative infinity) is positive infinity.If we multiply negative infinity with NaN, we will get NaN as a result.The product of NaN and negative infinity is 0.The product of two negative infinities is always a positive infinity.The product of both positive and negative infinity is always negative infinity.
Negative infinity results in 0 when divided by any other number.
When divided by itself or positive infinity, negative infinity return NaN
Negative infinity, when divided by any positive number (apart from positive infinity) is negative infinity.
Negative infinity, divided by any negative number (apart from negative infinity) is positive infinity.
If we multiply negative infinity with NaN, we will get NaN as a result.
The product of NaN and negative infinity is 0.
The product of two negative infinities is always a positive infinity.
The product of both positive and negative infinity is always negative infinity.
Syntax:
Number.NEGATIVE_INFINITY
Example 1:
<!DOCTYPE html><html>  <body>    <style>        h1 {            color: green;        }    </style>      <h1>GeeksforGeeks</h1>    <h1>      What is negative infinity in JavaScript?  </h1>      <button onclick="geekNegativeInfinity()">      Generate negative infinite  </button>      <p id="geek"></p>      <script>        function geekNegativeInfinity() {            //negative value greater than the             //largest representable number in JavaScript            var n = (-Number.MAX_VALUE) * 2;             document.getElementById("geek").innerHTML = n;        }    </script>  </body>  </html>
Output:
Example 2:
<script>    function checkNegativeInfinity(x) {        if (x === Number.NEGATIVE_INFINITY) {            return 'Number is -Infinity';        } else {            return 'Number is not -Infinity';        }    }  console.log(checkNegativeInfinity(2)); </script>
Output
Supported Browsers:
Google Chrome
Mozilla Firefox
Apple Safari
Opera
Internet Explorer/Edge
JavaScript-Misc
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?