Map and $.each (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var data= [["abc","def"],["dss","ddd"]];

Test runner

Ready to run.

Testing in
TestOps/sec
map
var json = data.map(function (value, key) {
    return {
        "wf": value[0],
        "sb": value[1]
    }
});
console.log(json);
ready
each
var b=[];
$.each(data,function(i,d){
  b.push({wf:d[0],sb:d[1]});
});

console.log(b);
ready
for
var b=[];
for(var i=0;i<data.length;i++)
{
  var d=data[i];
  b.push({wf:d[0],sb:d[1]});
};

console.log(b);
ready

Revisions

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