Saturday, October 18, 2025
HomeLanguagesJavascriptJavaScript Infinity Property

JavaScript Infinity Property

The Infinity Property is used to display Infinity when the floating point number’s upper limit is exceeded and -Infinity is displayed when the floating point number’s lower limit is exceeded. Here, Infinity denotes Positive Infinity, and -Infinity represents Negative Infinity. Also,  the upper limit of the floating point number is 1.7976931348623157e+308 and the lower limit is -1.797693134862316E+308

Syntax:

Infinity

Return:

Infinity // For positive infinity
-Infinity // For negative infinity 

Example 1: 

JavaScript




<script>
    function test() {
        console.log(
            -3.645464512375121213E+1203466 +
            "<br>"
            +3.4548643575312453512345E+1203466);
    }
    test();
</script>


Output:

-Infinity
Infinity

Example 2:

html




<body>
    <center>
        <h1 style="color: green;">
            neveropen
        </h1>
        <h3>
            Js Infinity property
        </h3>
        <button onclick="test()">
            Press
        </button>
        <p>
            1.797693134862315E+308 is
            the limit of a Floating Point Number.
        </p>
        <h4>
            Clicking the Press button will
            showcase the Javascript Infinity Property.
        </h4>
        <p id="gfg"></p>
    </center>
    <script>
        function test() {
            document.getElementById("gfg")
                      .innerHTML="-1.797693134862315E+309 will be replaced by: "+
                               -1.797693134862315E+309+
                                 "<br>"+
                                 "1.797693134862315E+309 will be replaced by: "
                               + 1.797693134862315E+309;
        }
    </script>
</body>


Output:  

 

To know more about the +ve infinity and -ve infinity please go through the attached links.

Supported Browsers: Since infinity is an ES1 feature it is supported by all browsers.

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS