concat() vs. push.apply()

JavaScript performance comparison

Test case created by Sean McGary

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var test_array = [];
   
    for(var i = 0; i < 100; i++){
        test_array.push(i);
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
concat
var foo = [].concat(test_array);
pending…
push
var arr = [];

arr.push.apply(arr, test_array);
pending…

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

Compare results of other browsers

0 comments

Add a comment