String concatenation
JavaScript performance comparison
Info
Different ways to concatenate strings together
Preparation code
<script>
Benchmark.prototype.setup = function() {
var a = 'a';
var c = ('' + Math.random().toFixed(100));
};
</script>
<script>
Benchmark.prototype.setup = function() {
var a = 'a';
var c = ('' + Math.random().toFixed(100));
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Direct concatenation |
|
pending… |
Individual += statements |
|
pending… |
Individual statements |
|
pending… |
Using Array#join |
|
pending… |
RegEx stache replacement |
|
pending… |
Comma Operator |
|
pending… |
Compare results of other browsers
Revisions
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:
- Revision 1: published
- Revision 2: published
- Revision 3: published
- Revision 7: published
- Revision 8: published
- Revision 10: published
- Revision 14: published by Redger
- Revision 15: published by collibra
- Revision 16: published
- Revision 17: published
- Revision 18: published
- Revision 19: published
- Revision 20: published
- Revision 21: published
- Revision 23: published
- Revision 25: published by Hans
- Revision 26: published
- Revision 27: published
- Revision 28: published
- Revision 29: published
- Revision 31: published
- Revision 32: published
- Revision 33: published
- Revision 34: published
- Revision 35: published
- Revision 36: published
- Revision 37: published
- Revision 38: published
- Revision 39: published
- Revision 40: published by ichi
- Revision 41: published
- Revision 42: published
- Revision 44: published
- Revision 45: published
- Revision 46: published
- Revision 47: published
0 comments