copy array: concat vs simple loop and assignment
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
mixedarray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 'a', 'b', 'c',
{
foo: true
}, [1, 2, 3], document, window]
};
Benchmark.prototype.teardown = function() {
mixedarray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 'a', 'b', 'c',
{
foo: true
}, [1, 2, 3], document, window]
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
concat() |
|
pending… |
looping |
|
pending… |
slice |
|
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 4: published
0 comments