children[0] vs firstChild (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.js"></script>
<ul id="element"><li id="item">1</li><li>2</li><li>3</li><li>4</li></ul>

Setup

var oEl;

Teardown


    console.log(oEl);
    if (oEl !== document.getElementById('item')) {
      throw new Error('Not the same object');
    }
  

Test runner

Ready to run.

Testing in
TestOps/sec
children[0]
oEl = document.getElementById('element').children[0];
ready
firstchild
oEl = document.getElementById('element').firstChild;
ready
jquery
oEl = $('#element').children(':first')[0];
ready

Revisions

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