Numer对象复写了Object对象的toString()方法。
(10).toString() === "10" // true
(010).toString() === "8" // true
(0x10).toString() === "16" // true
上面的结果实现需要两步:
1. 将数值转为10进制(无参数默认十进制)
2.将转后的十进制转为字符串
(10).toString(2) //"1010"
(010).toString(2) //"1000"
(0x10).toString(2) //"10000"
当toString(num)内有参数时:
1.将数值转为参数对应的进制(当没有时默认十进制)
2.将进制转为字符串
原文:https://www.cnblogs.com/lyraLee/p/10912804.html