title: Get every nth item in array
body: <p>I have an array of HTML elements. I'm checking whether a previous object in the array exists like this:</p>
  
  <pre><code>var boxes = $('.box'); // creating the array
  
  boxes.each(function(i){ // going through the array
      var prevBox = i&gt;0?$(boxes[i-1]):false; // check whether a previous box exists
      if (prevBox) { } // do something
      else { } // do something else
  });
  </code></pre>
  
  <p>This works well. But I would also need to check the existence of every fourth object (box) in the array, or more precisely whether an object three objects before the current one exists.</p>
  
  <p>This doesn't work:</p>
  
  <pre><code>var prevBox = i&gt;0?$(boxes[i-4]):false;
  </code></pre>
  
  <p>I believe using <code>jQuery.grep()</code> and checking if <code>(i % 4) == 0</code> might be the answer, but with my limited knowledge of Javascript, I don't know how to apply it to what I have now.</p>
  
  <p>Anyone can help? Thanks!</p>