示例

console.log(Math.random());                   // 0到1之间的随机浮点数。
console.log(Math.random() * 100);             // 0到100之间的随机浮点数。
console.log(Math.floor(Math.random() * 11));  // 0到10之间的一个随机整数。

说明

此方法返回一个介于0(包含)和1(不包括)之间的随机数。

语法

Math.random() ;
JavaScript Math random()方法

返回值

返回一个介于0(包括)和1(不包括)之间的随机数。

日期:2019-08-20 13:50:55 来源:oir作者:oir