1、取数组中的最大值,最小值
方案1
console.log(Math.min(3,12,23,18,25,33,22,30,1)) // 1
console.log(Math.max(3,12,23,18,25,33,22,30,1)) // 33
或
var arr = [3,12,23,18,25,33,22,30,1]
var min =eval("Math.min(" +arr.toString()+")"); // 1 采用字符串拼接
var max = eval("Math.max(" +arr.toString()+")");; // 33
console.log(min)
console.log(max)
2、数组去重
var arr = [3,12,23,18,25,33,22,30,1,30,1]
function unique( arr ){
return arr.filter(function(item,index){
return arr.indexOf(item,0) === index;
});
}
//微信号数组
// console.log(unique arr)); // [3,12,23,18,25,33,22,30,1]