jQuery .eq vs .get or [] inside $() (v2)

Revision 2 of this benchmark created by temp01 on


Description

Keep in mind, of course, that .eq is revertable with .end because .pushStack is used internally...

Preparation HTML

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

<script>
  // Create a whole bunch of elements for iteration.
  var elems = $('<div/>').append(Array(1000).join('<span/>')).children();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
.eq
elems.eq(0);
ready
.get
$(elems.get(0));
ready
[]
$(elems[0]);
ready
.slice
elems.slice(0, 1);
ready

Revisions

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