String concatenation
JavaScript performance comparison
Info
Different ways to concatenate strings together
Preparation code
<script>
var arr = ['a', 'b', 'c', 'd']
</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… |
Single individual statement |
|
pending… |
Using "\" to wrap string (no concat) |
|
pending… |
template-style replacement |
|
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
2 comments
Using "\" might be faster, but it won't validate if you run it through JSLint. Using that method would definitely raise concerns about future browser compatibility.
Error in last expression (use arr[match-1] instead arr[match])