Iterating over arrays
JavaScript performance comparison
Info
adding while
Preparation code
<script>
Benchmark.prototype.setup = function() {
var arr = Array(1000);
(function () {
for(var i=0; i<arr.length; i++) {
arr[i] = i;
}
}());
function assignValue(x) {
values.push(x);
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
forEach |
|
pending… |
for, counting up |
|
pending… |
for, counting up, caching length |
|
pending… |
for, counting down |
|
pending… |
for/in |
|
pending… |
while counting down |
|
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 Axel Rauschmayer
- Revision 3: published
- Revision 4: published by gotofritz
- Revision 5: published by johnjbarton
0 comments