Array.forEach vs native for
JavaScript performance comparison
Preparation code
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var values = Array(100);
for (var i=0; i < 100; i++) {
values[i] = i;
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Native for |
|
pending… |
Array.forEach |
|
pending… |
_.forEach |
|
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