📌  相关文章
📜  数组javascript代码示例的第二个最大值

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

代码示例1
var secondMax = function (){ 
    var arr = [20, 120, 111, 215, 54, 78]; // use int arrays
    var max = Math.max.apply(null, arr); // get the max of the array
    arr.splice(arr.indexOf(max), 1); // remove max from the array
    return Math.max.apply(null, arr); // get the 2nd max
};