jquery pseudo :eq vs finding by array index (v4)

Revision 4 of this benchmark created on


Preparation HTML

<div class="div"></div>
<div class="div"></div>
<div class="div"></div>
<div class="div"></div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var divElm=$('.div');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jquery pseudo :eq
var thirdDiv=$('.div:eq(2)');
ready
finding by array index
var thirdDiv=$($('.div')[2]);
ready
finding by array index with already cached element
var thirdDiv=$(divElm[2]);
ready
finding by eq on cached
var thirdDiv=divElm.eq(2);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.