JavaScript Math.random() 函數
Math.random() – 傳回0和1之間的僞随機數 可能為0,但總是小于1,[0,1)
1
document.write(Math.random());
傳回随機數
1
document.write(Math.random()(20-10+1)+10);
傳回10-20的随機數
1
document.write(Math.random()(n+1-m)+m);
傳回指定範圍的随機數(m-n之間)的公式
JavaScript Math.random() 函數
Math.random() – 傳回0和1之間的僞随機數 可能為0,但總是小于1,[0,1)
1
document.write(Math.random());
傳回随機數
1
document.write(Math.random()(20-10+1)+10);
傳回10-20的随機數
1
document.write(Math.random()(n+1-m)+m);
傳回指定範圍的随機數(m-n之間)的公式