Find largest array of arrays

Benchmark created on


Description

The objective is to find the largest element of a 2d array where you want the largest element of either the 1st or 2nd index of the sub array.

Setup

var data = [];
    
    while (data.length < 10000) {
    data.push([Math.random() * 100, Math.random * 300]);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Reduce
return data.reduce(function(max, arr) {
        return Math.max(max, arr[1]); 
        }, -Infinity);
ready
Map
return Math.max.apply(null, data.map(function(elem) {
  return elem[1];
}));
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.