Skip to content
Related Articles

Related Articles

Improve Article
ES6 | Number
  • Last Updated : 30 Sep, 2019

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:

PropertyDescription
Number.EPSILONThis property defines the smallest intervals between two numbers.
Number.MAX_SAFE_INTEGERThis property defines maximum safe integer in JavaScript(2^ 53 – 1).
Number.MAX_VALUEThis property defines constants for the largest possible positive numbers( 1.7976931348623157 x 10308).
Number.MIN_SAFE_INTEGERThis property defines the minimum safe integer constant(9007199254740991)
Number.MIN_VALUEThis property defines constants for the smallest possible positive numbers(5 x 10-324)
Number.NaNThis property defines Not-a-Number or unequal number.
Number.NEGATIVE_INFINITYThis property defines a value less than defined number.
Number.POSITIVE_INFINITYThis property defines a value greater than defined number.
Number.prototypeThis property defines special value representing infinity.

ES6 Number Methods: There are many functions mentioned below:



FunctionDescription
Number.isNaN() FunctionThis function returns whether the passed value is NaN or not.
Number.isFinite() FunctionThis function returns whether the passed value is a finite number.
Number.isInteger() FunctionThis function returns whether the passed value is an integer.
Number.isSafeInteger() FunctionThis function determines whether the passed value is a safe integer(-252 to 252).
Number.parseFloat() FunctionThis function is equivalent to parseFloat() of the global object.
Number.parseInt() FunctionThis function is equivalent to parseInt() of the global object.

ES6 Number Instances Methods:

FunctionDescription
toExponential() FunctionThis function returns string representing the number in exponential notation.
toFixed() FunctionThis function returns string representing the number in fixed-point notation.
toLocaleString() FunctionThis function returns string with a language sensitive representation of this number.
toPrecision() FunctionThis function returns string representing the number to a specified precision in fixed-point or exponential notation.
toString() FunctionThis function returns string representing the specified object in the specified radix.
valueOf() FunctionThis 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



My Personal Notes arrow_drop_up
Recommended Articles
Page :