Tutorialspoint.dev

JavaScript | Number.MAX_VALUE & Number.MIN_VALUE with Examples

Number.MAX_VALUE and Number.MIN_VALUE are used to represent maximum and minimum numeric value in javascript.

Syntax
 Number.MAX_VALUE 
 Number.MIN_VALUE 

Return Type

Both Number.MAX_VALUE and Number.MIN_VALUE returns a numeric value.

  • MAX_VALUE has a value of approximately 1.79E+308. The values which are larger Number.MAX_VALUE are termed as Infinity.
  • MIN_VALUE has a value of approximately 5e-324. The values which are smaller than Number.MIN_VALUE are termed as underflow values.
  • Both MAX_VALUE and MIN_VALUE are static property of Number. Therefore using x.MAX_VALUE or x.MIN_VALUE will return undefined where x is a Number or Number Object.
<script>
  
    // JavaScript Code to illustrate Number.MAX_VALUE
    // & Number.MIN_VALUE
  
    function func() {
        // MAX_VALUE
        var a = Number.MAX_VALUE;
        document.write(a);
  
        // New Line
        document.write("<br>");
  
        // MIN_VALUE
        a = Number.MIN_VALUE;
  
        document.write(a);
  
        // New Line
        document.write("<br>");
        a = 1
            // Undefined Behaviour
            document.write(a.MAX_VALUE);
    }
  
func();
< /script>                    

Output :
1.7976931348623157e+308
5e-324
undefined



This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter