JAVASCRIPT NUMBER OBJECT

NUMBER OBJECT:

The Number object represents numerical date, either integers or floating-point numbers.

The syntax for creating a number object is as follows:

var  val = new Number(number);

In the place of number, if you provide any non-number argument, then the argument cannot be converted into a number, it returns NaN (Not-a-Number).

Number properties:
  1. MAX_VALUE- The largest possible value a number in JavaScript can have 
  2. MIN_VALUE- The smallest possible value a number in JavaScript 
  3. NAN- Equal to a value that is not a number.
  4. NEGATIVE_INFINITY- A value that is less than MIN_VALUE
  5. POSITIVE_ INFINITY- A value that is greater than MAX_VALUE

Methods:
1.valueOf()-Returns the number's value.
2.toString()-Returns the string representation of the number's value
3.toFixed()-Formats a number with a specific number of digits to the right of the decimal.



No comments:

Post a Comment