Number数字对象的方法

2020-05-14  本文已影响0人  疯狂的蜗牛Dianna
Number对象的方法 number也可以用
1.toFixed(n) 保留小数点后n位
var num = 3.1415926;
console.log(num.toFixed(4));

打印结果: 3.1415

2.toString()转化为字符串
console.log(num.toString());

打印结果: 字符串类型的3.1415926

上一篇 下一篇

猜你喜欢

热点阅读