类似PHP的mt_rand(),找了下,函数如下:

function RandomNumBoth(Min,Max){
var Range = Max - Min;
var Rand = Math.random();
var num = Min + Math.round(Rand * Range); //四舍五入
return num;
}

代码来自:https://www.jb51.net/article/82747.htm

Related Posts: JavaScript 范围随机整数 :

avatar