jQuery objects in for loop as var vs reference

JavaScript performance comparison

Test case created by Rich

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<p>Hidden table so it looks prettier</p>
<table id="table" style="display:none;">
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr><tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
<tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr>
</table>
<script>
  var array1 = [];
  var array2 = [];
</script>
    

Preparation code output

<p>Hidden table so it looks prettier</p> <table id="table" style="display:none;"> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr><tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> <tr class="table-row"><td class="cell-1">apples</td><td class="cell-2">bananas</td><td class="cell-3">carrots</td><td class="cell-4">grapes</td></tr> </table> <script> var array1 = []; var array2 = []; </script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
for loop using jquery object reference
for (var array1_x = 0, array1len = $('#table').children().length; array1_x < array1len; array1_x++) {
 var row = $($('#table').children()[array1_x]);
 var child1 = $(row.children()[1]),
     child2 = $(row.children()[2]);
 if (child2.length) {
  array1.push(child1.attr('id'));
 }
}
pending…
for loop with jquery variable re-reference
for (var array2_x = 0, array2len = $('#table').children().length; array2_x < array2len; array2_x++) {
 if ($($($('#table').children()[array2_x]).children()[2]).length) {
  array2.push($($($('#table').children()[array2_x]).children()[1]).attr('id'));
 }
}
pending…

Compare results of other browsers

Revisions

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

1 Comment

Rich (revision owner) commented :

So it's faster to refer to a jQuery lookup'd object that to refind it - no surprises there.

Hidden table so it looks prettier