jquery .each VS for loops
JavaScript performance comparison
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
$.each |
|
pending… |
for (var i = 0, len = list.length) |
|
pending… |
for ( in ) |
|
pending… |
for (var i = 0) |
|
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 Jasper
- Revision 2: published by Jasper Howard
- Revision 3: published
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published by Jasper Howard
- Revision 8: published
- Revision 9: published by Kiennv
0 comments