Cloning Arrays (v4)

Revision 4 of this benchmark created on


Setup

var a = [];
  for (var i = 0; i < 2000; i++) {
    a[i] = i;
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Slice
var b = a.slice();
b[299] = b[300];
ready
Concat
var b = a.concat();
b[299] = b[300];
ready
Concat 2
var b = [].concat(a);
b[299] = b[300];
ready
Slice with 0 index
var b = a.slice(0);
b[299] = b[300];
ready
Map
var b = a.map(function(e) {
    return (e);
});
b[299] = b[300];
ready

Revisions

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