join vs plus

JavaScript performance comparison

Test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var string0 = "I AM A STRING";
  var string1 = "I AM ALSO A STRING";
  var string2 = "I AM NO DIFFERENT THAN THE OTHERS";
  var string3 = "I AM STARTING TO RUN OUT OF CLEVER THINGS TO SAY";
  var string4 = "5 OF THESE SHOULD BE GOOD";

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
join 2
var output0 = [string0, string1].join("");
pending…
plus 2
var output0 = string0 + string1;
pending…
join 5
var output0 = [string0, string1, string2, string3, string4].join("");
pending…
plus 5
var output0 = string0 + string1 + string2 + string3 + string4;
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