Iterate array non-sequentially <p>I am working with an array of objects (tweets) and I only want to iterate over a certain number of those objects on each page load. Where the last count stopped iterating will be saved and started there again on the next page load. This is where I'm stuck.</p> <pre><code>var obj1 = [{ "name": "trai" }, { "name": "beth" }, { "name": "taylor" }, { "name": "trace" }, { "name": "dad" }, { "name": "elaine" }]; var i = 5; //last index. will be updated and retrieved in browser storage var num = 2; //number to iterate for (var count = 0; count &lt; num; count++) { $('body').append('&lt;div&gt;' + obj1[i].name + '&lt;/div&gt;'); if (i &gt;= obj1.length) { i = 0; } else {i++;} } </code></pre>