js中Math.random()的运用方法

2025年02月28日 建站教程

js中的Math.random()有什么用?下面web建站小编给大家详细介绍一下!

Math.random()是用来生成随机数的,我们可以利用它来随机显示一些文章。

实现代码如下:

function random() {
  return arguments[Math.floor(Math.random() * arguments.length)]
}
var randomCon = random("苹果笔记本", "华为笔记本", "苹果手机", "摆件", "安慰奖", "谢谢");
console.log('抽奖:', randomCon)

本文链接:http://so.lmcjl.com/news/24032/

展开阅读全文
相关内容