Insert char at given position in string
JavaScript performance comparison
Info
It is cheaper to insert chart at given position using substr and + or it is better to split the string, splice it and then join?
Preparation code
<script>
Benchmark.prototype.setup = function() {
var content = "This is my string, which is that long";
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
using substr and + |
|
pending… |
using split, splice, join |
|
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 2: published by JM
0 comments