标签:
var x = Math.floor(Math.random() * (max - min + 1)) + min;
function arrayRandomValue(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
var a = [1, 2, 3, 3, 4, 5, 6, 7, 8, 9];
arrayRandomValue(a);
var numbers = [1, 2, 3, 4, 5, 6];
// Math对象内置方法max
var max = Math.max.apply(null, numbers);
// 数组排序方法sort
var max = numbers.sort(function(a, b){
return b - a;
})[0];
JavaScript Snippet - Array【原】 2016-2-19
标签:
原文地址:http://www.cnblogs.com/happyfreelife/p/5379234.html