返回介于0(包含)~1(包含)之間的一個隨機數
Math.random()
返回介于1(包含)~10(包含)之間的一個隨機數
Math.floor((Math.random()*10)+1);
返回介于min(包含)~max(包含)之間的一個隨機數
function getRndInteger(min, max) { return Math.floor(Math.random() * (max - min) ) + min;}
Math.random()
Math.floor((Math.random()*10)+1);
function getRndInteger(min, max) { return Math.floor(Math.random() * (max - min) ) + min;}
非特殊說明,本博所有文章均為博主原創。
如若轉載,請注明出處:http://www.sui9.com/view/47.html