Obviously filter is not the write function for that, but:
Math.max.apply(0, array);
If anyway you want to do this with filter, you can do something like this.
var arr = [...];
var a = arr[0];
var b = arr.filter(function(i){
if (i > a) {
a = i;
}
return i == a;
});
return b[b.length - 1];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…