Number.toString('hex')
Number.toString()可以传'hex'作参数吗?
Number.toString()可以传'hex'作参数吗?
2017-04-27
NOTEThe optional radix should be an integer value in the inclusive range 2 to 36. If radix not present or is undefined the Number 10 is used as the value of radix.
The following steps are performed:
Let x be thisNumberValue(this value).
ReturnIfAbrupt(x).
If radix is not present, let radixNumber be 10.
Else if radix is undefined, let radixNumber be 10.
Else let radixNumber be ToInteger(radix).
ReturnIfAbrupt(radixNumber).
If radixNumber < 2 or radixNumber > 36, throw a RangeError exception.
If radixNumber = 10, return ToString(x).
Return the String representation of this Number value using the radix specified by radixNumber. Letters a
-z
are used for digits with values 10 through 35. The precise algorithm is implementation-dependent, however the algorithm should be a generalization of that specified in 7.1.12.1.
The toString
function is not generic; it throws a TypeError exception if its this value is not a Number or a Number object. Therefore, it cannot be transferred to other kinds of objects for use as a method.
举报