Array map and join vs loop and string concatenation

JavaScript performance comparison

Revision 60 of this test case created

Preparation code

    var data = Array.apply (null, new Array (1e4))
        .map (function (a, i){ return i });
    function fn (arg){
        return arg.toString (2);

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Array map and join
var output = (fn).join ('; ');
Loop and string concatenation
var output = fn (data [0]);

for (var i = 1; i < data.length; i ++)
    output += '; ' + fn (data [i]);
var output = myarray.join('');

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Comment form temporarily disabled.

Add a comment