js随机生成[n,m)的数字(不包括m)

mac2022-06-30  116

Math.random();//随机生成0到1的数字

Math.floor();//取小整

Math.floor(Math.random()*(最大值 - 最小值) + 最小值)

生成2到8的数:Math.floor(Math.random()*(8 - 2) + 2)

转载于:https://www.cnblogs.com/YAN-HUA/p/9410578.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)