JQuery 2.0.3: first vs .first() vs. eq (v13)

Revision 13 of this benchmark created by Pablo Armentano on


Description

Fixed test for [0], get(0), slice(0, 1) because they returns DOM element not JQ-element.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<div>AAAA</div>
<div>BBBB</div>
<div>CCCC</div>
<div>DDDD</div>
<div>EEEE</div>

<div><span>aaaa</span></div>
<div><span>bbbb</span></div>
<div><span>cccc</span></div>
<div><span>dddd</span></div>
<div><span>eeee</span></div>

Test runner

Ready to run.

Testing in
TestOps/sec
.first
$("div").first();
ready
:first
$("div:first");
ready
get(0)
$($("div").get(0));
ready
[0]
$($("div")[0]);
ready
.eq
$("div").eq(0);
ready
.filter(:first)
$("div").filter(":first");
ready
slice
$($("div").slice(0,1));
ready
:eq(0)
$("div:eq(0)");
ready

Revisions

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