String Concat vs Array join
JavaScript performance comparison
Info
Comparing speed of string concatenation vs pushing to an array and then joining at the end.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var quantum = 'abcd';
var emptyArray = [];
var emptyString = '';
};
Benchmark.prototype.teardown = function() {
var finalStringFromArray = emptyArray.join(' ');
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
String concat |
|
pending… |
Array join |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments