Array.forEach vs native for
JavaScript performance comparison
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js"></script>
<script>
Benchmark.prototype.setup = function() {
var values = [];
for (var i=0; i<10000; i++) {
values[i] = i;
}
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Array.forEach |
|
pending… |
Native for |
|
pending… |
w/o caching values.length |
|
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 The Beard
- Revision 2: published
- Revision 3: published by Thomas Upton
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 8: published by Benjamin
0 comments