last vs first (v2)

Revision 2 of this benchmark created by alsh on


Preparation HTML

<ul>
</ul>

Setup

var ul = document.querySelector('ul');
    for (var i = 0; i < 1000; i++) {
      var li = document.createElement('li');
      li.textContent = 'plop' + i;
      ul.appendChild(li);
    }

Teardown


    ul.textContent = '';
  

Test runner

Ready to run.

Testing in
TestOps/sec
firstElementChild
ul.firstElementChild;
ready
lastElementChild
ul.lastElementChild;
ready
children[0]
ul.children[0]
ready
children[last-1]
ul.children[ul.children.length - 1]
ready

Revisions

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