📌  相关文章
📜  从数组中选择随机值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:23.445000             🧑  作者: Mango

代码示例5
//Function to make it easier
Array.prototype.random = function() {
    return this[Math.floor((Math.random() * this.length))];
};

var colors = ["red","blue","green","yellow"];
var randomColor = colors.random();