1:把数字转换为字符串的方法
复制代码 代码如下:
var string_value = string(number);
string_value = number.tostring(); var n = 17;
binary_string = n.tostring(2); //evaluates to 10001
octal_string = 0 + n.tostring(8); //evaluates to 021
hex_string = 0x + n.tostring(16); //evaluates to 0x11
var n = 123456.789;
n.tofixed(0); //1234567
n.tofixed(2); //123456.79
n.toexponential(1); //1.2e+5
n.toexponential(3); //1.235e+5
n.toprecision(4); //1.235e+5
n.toprecision(7); //123456.8