foreach loop 1000 items multiple times : <p>In javascript I have an array of something like 500,000 items.</p>

<p>I want to send to server 1000 items  multiple times.</p>

<p>Seems that I need to use the <code>Slice Function</code>.</p>

<p>How can I do it send 1000 items each time and the last time send the last items. either if it less than 1000 items.</p>
