jQuery each vs JS forEach
JavaScript performance comparison
Preparation code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
// Setup collection
var collection = [];
for (var i = 0; i < 20000; i++) {
collection.push({
index: i,
data: 'Index element ' + 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 | |
---|---|---|
jQuery
|
|
pending… |
JS forEach()
|
|
pending… |
JS for(var x in collection)
|
|
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.
- Revision 1: published John
- Revision 2: published Christopher Froehlich
- Revision 3: published
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 10: published
- Revision 11: published
- Revision 12: published Mario
- Revision 13: published
- Revision 18: published
- Revision 19: published
- Revision 20: published
- Revision 21: published
- Revision 22: published
- Revision 23: published
- Revision 24: published
- Revision 25: published john hicks
- Revision 26: published
- Revision 27: published
- Revision 28: published
- Revision 29: published
- Revision 30: published Chaitanya
- Revision 31: published Chaitanya
- Revision 32: published
- Revision 33: published
- Revision 34: published JonB
- Revision 35: published
- Revision 38: published
- Revision 40: published
0 Comments