random函数语法

Math.random();

random函数参数

无参数

random函数返回值

返回0和1之间的伪随机数,可能为0,但总是小于1,[0,1)

random函数示例

document.write(Math.random());

返回随机数

document.write(Math.random()*(20-10)+10);

返回10-20的随机数

document.write(Math.random()*(n-m)+m);

返回指定范围的随机数(m-n之间)的公式

相关文章:

  • 2022-12-23
  • 2021-11-11
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-24
  • 2021-07-15
  • 2022-03-05
  • 2021-08-27
  • 2021-11-30
  • 2021-12-30
  • 2021-12-04
相关资源
相似解决方案