copy simple array
JavaScript performance comparison
Info
Quickest way to get a byval copy of an array of simple values - will NOT copy immutable objects in arrays byval e.g. nested arrays / objects etc get copied BYREF.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var a = [1, 2, 3, 4, 5, 6, 7, 8, 9],
b = null;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
concat |
|
pending… |
slice w/index |
|
pending… |
slice w/o index |
|
pending… |
[] |
|
pending… |
new Array |
|
pending… |
loop |
|
pending… |
push |
|
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 by justageezer
- Revision 2: published
- Revision 3: published
0 comments