Using NEGATIVE_INFINITY in JavaScript

Last Reply 2 months ago By dharmendr

Posted 2 months ago

Hello Everyone,

I am new here and I want to know about NEGATIVE_INFINITY in JavaScript. I am learning javascript and I have one doubt NEGATIVE_INFINITY is a static property in JS that results? Can anyone know about it?

Posted 2 months ago

Hi ankit09,

NEGATIVE_INFINITY is a static property of the JavaScript Number object.

You can only use it as Number.NEGATIVE_INFINITY.

Using x.NEGATIVE_INFINITY, where x is a number or a Number object will return undefined.

Syntax

Number.NEGATIVE_INFINITY;

Example

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script> 
        window.onload = function () {
            alert(Number.NEGATIVE_INFINITY);
            var x = 100;
            alert(x.NEGATIVE_INFINITY);
        }
    </script>
</head>
<body>
</body>
</html>

Demo

For more details refer below link.

https://www.w3schools.com/jsref/jsref_negative_infinity.asp