Is Previous the first-child? (v2)

Revision 2 of this benchmark created on


Description

Check if previous element is first child

Preparation HTML

<div>
<ul>
  <li>First</li>
  <li id="second">Second</li> 
</ul>
</div>

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

Test runner

Ready to run.

Testing in
TestOps/sec
Using .is(':first-child')
$('#second').prev().is(':first-child');
ready
Using .index()
$('#second').prev().index();
ready
Using .prev(':first-child')
$('#second').prev(':first-child');
ready

Revisions

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