title: In a nested for loop, is there any advantage in starting with the longer loop? Or vice versa?
body: <p>For example:</p>
  
  <pre><code>var longArray = [1, 2, 3, 4]
  var shortArray = [2, 3]
  </code></pre>
  
  <p>Which one is faster?</p>
  
  <p>Long loop first:</p>
  
  <pre><code>for (var i = 0; i &lt; longArray.length; i++) {
    for (var j = 0; j &lt; shortArray.length; j++) {
      if (longArray[i] === shortArray[j]) {
        // do something
      }
    }
  }
  </code></pre>
  
  <p>Or short loop first:</p>
  
  <pre><code>for (var i = 0; i &lt; shortArray.length; i++) {
    for (var j = 0; j &lt; longArray.length; j++) {
      if (longArray[i] === shortArray[j]) {
        // do something
      }
    }
  }
  </code></pre>
  
  <p>Or are there any advantages in either that I'm not considering? Or does it not matter at all?</p>