Skip to content
Related Articles

Related Articles

Improve Article

JavaScript Number Static Properties

  • Difficulty Level : Medium
  • Last Updated : 26 Mar, 2021

The JavaScript Number is an object that can represent numeric values like integer, float, hexadecimal, decimal, etc. It acts as a wrapper object for primitive numeric values. It has various methods and properties that are used to perform different tasks on numbers. The following table shows some static properties of the Number object that can be used throughout a program as constants.

Property:

  • MAX_VALUE: It returns the maximum number value that is supported in JavaScript.
  • MIN_VALUE: It returns the smallest positive numeric value that is closest to 0, but, not the most negative number.
  • NEGATIVE_INFINITY: It represents the negative infinity value.
  • POSITIVE_INFINITY: It represents the positive infinity value.
  • MIN_SAFE_INTEGER: It represents the minimum safe integer in JavaScript.
  • NaN: It is used for representing a value that is not a legal number.

The below examples demonstrate how these properties of the Number are used.

Example 1: In this example, we find out the maximum and minimum values supported in JavaScript.

HTML




<html>
<body>
  <h1>
    Number properties max value
    and min value
  </h1>
  <script>
    console.log('Maximum Value:',
                Number.MAX_VALUE);
    console.log('Minimum Value:',
                Number.MIN_VALUE);
  </script>
</body>
</html>

Console Output:

Maximum Value: 1.7976931348623157e+308
Minimum Value: 5e-324

Example 2: In this example, we find out the positive and negative infinity values in JavaScript.

HTML




<html>
<body>
  <h1>
    Number properties negative
    infinity and positive infinity
  </h1>
  <script>
    console.log('Negative Infinity:',
                Number.NEGATIVE_INFINITY);
    console.log('Positive Infinity:',
                Number.POSITIVE_INFINITY);
  </script>
</body>
</html>

Console Output:

Negative Infinity: -Infinity
Positive Infinity: Infinity



My Personal Notes arrow_drop_up
Recommended Articles
Page :