var arr = [1,2,3,4,5,2,2,4,52,5,6,5,4,4]; var maxNum = Math.max.apply(Math,arr); var maxIndex = arr.indexOf(Math.max.apply(Math,arr)) console.log(maxNum); console.log(maxIndex); var es6Max = Math.max(...arr); console.log(es6Max)
var arr = [1,2,3,4,5,2,2,4,52,5,6,5,4,4]; var maxNum = Math.max.apply(Math,arr); var maxIndex = arr.indexOf(Math.max.apply(Math,arr)) console.log(maxNum); console.log(maxIndex); var es6Max = Math.max(...arr); console.log(es6Max)
转载于:https://www.cnblogs.com/mr-pz/p/5890608.html