Global.Infinity

JavaScript 1.3+, JScript 1.0+ Nav4.06+, IE 3+, Opera3+ Syntax

Infinity

Description

Infinity is a JavaScript keyword that represents positive infinity.

Example

Listing 6.136 shows how the Infinity keyword is used. An input text box is provided to enter a value to be compared to Infinity. If any number is entered, it will result in being less than Infinity. However, if the word Infinity is entered, it will result in being equal to Infinity.

Listing 6.136 Example of Using the Infinity Property
 <html> <body> <script language = "JavaScript"> <!–– Hide // function checks to see if the input is greater, less than, or equal // to the value input by the user. function checkNum(){ input=document.form1.num.value; if(input < Infinity){ ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.