ES6 | Number
The ES6 Number contains so many properties and methods to perform some numeric functions, that contains the date, integers, and floating points, etc. The ES6 is an object that can be called without creating it. With the help of ES6 Number in JavaScript, you can work with number objects so easily because the browsers convert number literals to instances of the number class automatically. There are so many properties and functions are available in ES6 Number. Also in the function section, there are lots of functions mentioned below. Below syntax will create number object.
Syntax:
var geeks = new Number(number);
ES6 Number methods type:
- Number Methods
- Number Instances Methods
ES6 Number properties list with there brief description:
| Property | Description |
|---|---|
| Number.EPSILON | This property defines the smallest intervals between two numbers. |
| Number.MAX_SAFE_INTEGER | This property defines maximum safe integer in JavaScript(2^ 53 – 1). |
| Number.MAX_VALUE | This property defines constants for the largest possible positive numbers( 1.7976931348623157 x 10308). |
| Number.MIN_SAFE_INTEGER | This property defines the minimum safe integer constant(9007199254740991) |
| Number.MIN_VALUE | This property defines constants for the smallest possible positive numbers(5 x 10-324) |
| Number.NaN | This property defines Not-a-Number or unequal number. |
| Number.NEGATIVE_INFINITY | This property defines a value less than defined number. |
| Number.POSITIVE_INFINITY | This property defines a value greater than defined number. |
| Number.prototype | This property defines special value representing infinity. |
ES6 Number Methods: There are many functions mentioned below:
| Function | Description |
|---|---|
| Number.isNaN() Function | This function returns whether the passed value is NaN or not. |
| Number.isFinite() Function | This function returns whether the passed value is a finite number. |
| Number.isInteger() Function | This function returns whether the passed value is an integer. |
| Number.isSafeInteger() Function | This function determines whether the passed value is a safe integer(-252 to 252). |
| Number.parseFloat() Function | This function is equivalent to parseFloat() of the global object. |
| Number.parseInt() Function | This function is equivalent to parseInt() of the global object. |
ES6 Number Instances Methods:
| Function | Description |
|---|---|
| toExponential() Function | This function returns string representing the number in exponential notation. |
| toFixed() Function | This function returns string representing the number in fixed-point notation. |
| toLocaleString() Function | This function returns string with a language sensitive representation of this number. |
| toPrecision() Function | This function returns string representing the number to a specified precision in fixed-point or exponential notation. |
| toString() Function | This function returns string representing the specified object in the specified radix. |
| valueOf() Function | This function returns primitive value of the specified object. |
In the ES6 Number there are three important representing Literals those are:
- Binary Literals
- Octal Literals
- Hexadecimal Literals
Binary Literals: You can represent binary literals with the 0b prefix it can be used as uppercase or lowercase does not matter.
<script> console.log(0b001) console.log(0b010) </script> |
Output:
1 2
Octal Literals: You can represent octal literals with the 0o prefix it can be used as uppercase or lowercase does not matter.
<script> console.log(0o010) console.log(0o001) </script> |
Output:
8 1
Hexadecimal Literals: You can represent hexadecimal literals with the 0x prefix it can be used as uppercase or lowercase does not matter.
<script> console.log(0x010) console.log(0x100) </script> |
Output:
16 256
Note: The Edge and the Safari is the first two browsers that support all the ES6 features.
Supported Browsers: The browsers supported by ES6 Number are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
Recommended Posts:
- Puzzle | Number of Sheets to be turned so that Prime Number has a Vowel on the other side
- How to disable scroll to change number in <input type="number"> field using JavaScript/jQuery?
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Number of leading zeros in binary representation of a given number
- JavaScript | Number.MAX_VALUE & Number.MIN_VALUE with Examples
- Finding number of digits in n'th Fibonacci number
- How to convert a float number to the whole number in JavaScript?
- Number of pairs with Bitwise OR as Odd number
- Nth number in a set of multiples of A , B or C
- Sum of every K’th prime number in an array
- Number.isNaN() In JavaScript
- Number of subsets with product less than k
- What is the difference between parseInt() and Number()?
- First digit in factorial of a number
- How to convert a string into number in PHP?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


