I know this gets asked again and again but hear me out - this question is slightly different.
I can get a max or min from a 1D array like this:
var
for big 2D arrays use this avoid function.prototype.apply as in above almost all answers i can see it. because it can handle only limited amount of array length .
function MaxMin2dray(arr, idx){
var max = Number.MIN_VALUE;
var min = Number.MAX_VALUE;
arr.forEach(function(e) {
if (max < e[idx]) {
max = e[idx];
}
if (min > e[idx]) {
min = e[idx];
}
});
return {max: max, min: min};
}