Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
IE 11
Windows 7
Other
8 years ago
Test name Executions per second
Use eq 303173.3 Ops/sec
Use get 574176.9 Ops/sec
Use array like access 490765.8 Ops/sec
HTML Preparation code:
AخA
 
1
<div id="testRoot">
2
  <span>1</span>
3
  <span>1</span>
4
  <span>1</span>
5
  <span>1</span>
6
  <span>1</span>
7
  <span>1</span>
8
  <span>1</span>
9
</div>
Script Preparation code:
 
var elements = $("#testRoot span");
var len = elements.length;
Tests:
  • Use eq

     
    for (var i = 0; i < len; i++){
      var t = elements.eq(i).textContent;
    }
  • Use get

     
    for (var i = 0; i < len; i++){
      var t = elements.get(i).textContent;
    }
  • Use array like access

     
    for (var i = 0; i < len; i++){
      var t = elements[i].textContent;
    }