Is Previous the first-child? (v4)

Revision 4 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 prev().index()
!$('#second').prev().index();
ready
Using index() == 1
$('#second').index() === 1
ready

Revisions

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