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.
Syntax:
var neveropen = new Number(number);
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.
Example: This example shows the binary literals.
javascript
console.log(0b001); console.log(0b010); |
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.
Example: This example shows the octal literals.
javascript
console.log(0o010); console.log(0o001); |
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.
Example: This example shows the Hexadecimal literals.
javascript
console.log(0x010); console.log(0x100); |
Output:
16 256
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.EPSILON |
Number.MAX_SAFE_INTEGER |
This property defines the maximum safe integer in JavaScript(2^ 53 – 1). Number.MAX_SAFE_INTEGER |
Number.MAX_VALUE |
This property defines constants for the largest possible positive numbers( 1.7976931348623157 x 10308). Number.MAX_VALUE |
Number.MIN_SAFE_INTEGER |
This property defines the minimum safe integer constant(9007199254740991) Number.MIN_SAFE_INTEGER |
Number.MIN_VALUE |
This property defines constants for the smallest possible positive numbers(5 x 10-324) Number.MIN_VALUE |
Number.NaN |
This property defines Not-a-Number or unequal number. var a = NaN |
Number.NEGATIVE_INFINITY |
This property defines a value less than a defined number. Number.NEGATIVE_INFINITY |
Number.POSITIVE_INFINITY |
This property defines a value greater than a defined number. var a = Number.POSITIVE_INFINITY |
Number.prototype |
This property defines a special value representing infinity. Number.prototype.toPrecision |
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.isNaN(value) |
Number.isFinite() Function |
This function returns whether the passed value is a finite number. Number.isFinite(value) |
Number.isInteger() Function |
This function returns whether the passed value is an integer. Number.isInteger(value) |
Number.isSafeInteger() Function |
This function determines whether the passed value is a safe integer(-252 to 252). Number.isSafeInteger(Value) |
Number.parseFloat() Function |
This function is equivalent to parseFloat() of the global object. parseFloat(Value) |
Number.parseInt() Function |
This function is equivalent to parseInt() of the global object. parseInt(Value, radix) |
ES6 Number Instances Methods:
Function | Description |
---|---|
toExponential() Function |
This function returns a string representing the number in exponential notation. number.toExponential(value) |
toFixed() Function |
This function returns a string representing the number in fixed-point notation. number.toFixed( value ) |
toLocaleString() Function |
This function returns a string with a language-sensitive representation of this number. number.toLocaleString(locales, options) |
toPrecision() Function |
This function returns a string representing the number to a specified precision in fixed-point or exponential notation. number.toPrecision(value) |
toString() Function |
This function returns a string representing the specified object in the specified radix. num.toString(base) |
valueOf() Function |
This function returns the primitive value of the specified object. number.valueOf() |
Note: The Edge and 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