javascript Number object

属性

属性 描述
Number.MAX_VALUE The largest representable number (±1.7976931348623157e+308)
Number.MIN_VALUE The smallest representable number (±5e-324)
Number.NaN Special “not a number” value
Number.NEGATIVE_INFINITY Special negative infinite value; returned on overflow
Number.POSITIVE_INFINITY Special positive infinite value; returned on overflow
Number.EPSILON Difference between 1 and the smallest value greater than 1 that can be represented as a Number (2.220446049250313e-16)
Number.MIN_SAFE_INTEGER Minimum safe integer in JavaScript (−253 + 1, or −9007199254740991)
Number.MAX_SAFE_INTEGER Maximum safe integer in JavaScript (+253 − 1, or +9007199254740991)

方法

Method Description
Number.parseFloat() Parses a string argument and returns a floating point number.Same as the global parseFloat() function.
Number.parseInt() Parses a string argument and returns an integer of the specified radix or base.Same as the global parseInt() function.
Number.isFinite() Determines whether the passed value is a finite number.
Number.isInteger() Determines whether the passed value is an integer.
Number.isNaN() Determines whether the passed value is NaN. More robust version of the original global isNaN().
Number.isSafeInteger() Determines whether the provided value is a number that is a safe integer.

Methods of Number.prototype

Method Description
toExponential() Returns a string representing the number in exponential notation.
toFixed() Returns a string representing the number in fixed-point notation.
toPrecision() Returns a string representing the number to a specified precision in fixed-point notation.

参考:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates

发布了1794 篇原创文章 · 获赞 582 · 访问量 154万+

猜你喜欢

转载自blog.csdn.net/claroja/article/details/104312351