• JavaScript Video Tutorials

JavaScript Number MIN_VALUE Property



The JavaScript Number MIN_VALUE property returns the minimum (or smallest) numeric value possible in JavaScript. If a value is smaller than the MIN_VALUE, it will be converted to zero (0).

It is a static property of the Number object. You always use it as a "Number.MIN_VALUE", rather than as a property of a number value. If you use x.MIN_VALUE, where 'x' is a variable, it will return 'undefined'.

Syntax

Following is the syntax of JavaScript Number MIN_VALUE property −

Number.MIN_VALUE

Parameters

  • It does not accept any parameters.

Return value

It returns the minimum numeric value representable in JavaScript i.e "2-1074, or 5E-324".

Example 1

The following example demonstrates the usage of the JavaScript Number MIN_VALUE property.

<html>
<head>
<title>JavaScript MIN_VALUE</title>
</head>
<body>
<script>
   document.write("MIN_VALUE = ", Number.MIN_VALUE);
</script>
</body>
</html>

Output

The above program returns minimum possible value as "5e-324".

MIN_VALUE = 5e-324

Example 2

If you try to access the MIN_VALUE property using a variable (e.g. x.MIN_VALUE), the output would be "undefined".

<html>
<head>
<title>JavaScript MIN_VALUE</title>
</head>
<body>
<script>
   let x = 15;
   document.write("Variable value = ", x);
   document.write("<br>MIN_VALUE = ", x.MIN_VALUE);
</script>
</body>
</html>

Output

Once the above program is executed, it will return an 'undefined'.

Variable value = 15
MIN_VALUE = undefined

Example 3

The following code divides two numeric values. If the result is greater than or equal to MIN_VALUE, the greater() function will be called; otherwise, the smaller() function will be called.

<html>
<head>
<title>JavaScript MAX_VALUE</title>
</head>
<body>
<script>
   function greater(){
      document.write("Greater function called...!");
   }
   function smaller(){
      document.write("Smaller function called...!");
   }
   let n1 = 10;
   let n2 = 20;
   document.write("Values are: ", n1 , " and ", n2, "<br>");
   let result = n1 / n2;
   document.write("Result is: ", result, "<br>");
   if(result >= Number.MIN_VALUE){
      greater();
   }
   else{
      smaller();
   }
</script>
</body>
</html>

Output

After executing the above program, it will produce the following output −

Values are: 10 and 20
Result is: 0.5
Greater function called...!
Advertisements