ES6 Everyday: New Number Methods and Properties
(After this post, I’ll be taking a week off, so I’ll see you all in a week!)
New Methods
A couple new methods have been added on to the Number
object:
- Number.isInteger(): Determines whether or not a value is an integer
- Number.isSafeInteger(): Determines whether or not a value is a “safe” integer (essentially, whether or not the value can be exactly represented as an IEEE-754 double precision number)
Moved Methods
A couple methods that were originally global methods have now been moved to the Number
object:
- Number.isFinite(): Determines if a value is a finite number
- Number.isNaN(): Determines if a value is
NaN
In their global forms, both of these methods would convert a non-number parameter into a number. This is no longer true.
New Properties
Along with new methods, some new properties have been added too:
- Number.EPSILON: Equal to the difference between 1 and the smallest value greater than 1
- Number.MAX_SAFE_INTEGER: Equal to the maximum safe integer
- Number.MIN_SAFE_INTEGER: Equal to the minimum safe integer