MDN地址:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/toString
toString() 方法返回指定 Number 对象的字符串表示形式
numObj.toString([radix]) 参数是指定要用于数字到字符串的转换的基数(从2到36)。如果未指定 radix 参数,则默认值为 10
如果转换的基数大于10,则会使用字母来表示大于9的数字,比如基数为16的情况,则使用a到f的字母来表示10到15。
如果基数没有指定,则使用 10。
如果对象是负数,则会保留负号。即使radix是2时也是如此:返回的字符串包含一个负号(-)前缀和正数的二进制表示,不是 数值的二进制补码。
进行数字到字符串的转换时,建议用小括号将要转换的目标括起来,防止出错
Math.random(): 输出0到1(包括0,不包含1)的随机数
toString(16): 将随机数转换为16进制的字符串
example:
var count = 10;
console.log(count.toString());
console.log((17).toString());
console.log((17.2).toString());
var x = 6;
console.log(x.toString(2));
console.log((254).toString(16));
console.log((-10).toString(2));
console.log((-0xff).toString(2));