Javascript 一个随机数向下取整实现(借助位运算~)

Math.floor()

Math.floor(Math.random()*9)

还有一种比较简单的实现方法,借助位运算~

~~

~~ Math.random()*9

猜你喜欢

转载自blog.csdn.net/u013270347/article/details/81986132