这个问题在这里已有答案:
想知道<<
在这方面做了什么:
Math.random() * Math.pow(36, 2) << 0
不确定如何在实践中使用它。
它截断数字/将其转换为整数。你可以自己测试一下:
console.log(12.345 << 0); // 12
- 这个问题与Why does a shift by 0 truncate the decimal?非常相似
看看这个
a = Math.pow(36, 2)
1296
a = Math.random() * a
477.5906135469167
a = a << 0
477