Tutorials Point


  JavaScript Basics
  JavaScript Objects
  JavaScript Advanced
  JS Useful References
  JS Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Javascript Number - NEGATIVE_INFINITY


previous next AddThis Social Bookmark Button


Advertisements

Description:

This is a special numeric value representing a value less than Number.MIN_VALUE. This value is represented as "-Infinity". This value resembles an infinity in its mathematical behavior. For example, anything multiplied by NEGATIVE_INFINITY is NEGATIVE_INFINITY, and anything divided by NEGATIVE_INFINITY is zero.

Because NEGATIVE_INFINITY is a constant, it is a read-only property of Number.

Syntax:

You can access this property using the following syntax:

var val = Number.NEGATIVE_INFINITY;

Example:

Here is an example showing usage of this property:

<html>
<head>
<script type="text/javascript">
<!--
function showValue()
{
   var smallNumber = (-Number.MAX_VALUE) * 2
   if (smallNumber == Number.NEGATIVE_INFINITY) {
      alert("Value of smallNumber : " + smallNumber );
   }
}
//-->
</script>
</head>
<body>
<p>Click the following to see the result:</p>
<form>
<input type="button" value="Click Me" onclick="showValue();" />
</form>
</body>
</html>

This will produce following result:

Value of val : -Infinity

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements