Do you want it in 2 section chunks?
var o = ['a', 'b', 'c', 'd', 'e', 'f'],
size = 2, i, ar = []; // The new array
for (i = 0; i < o.length; i += size) ar.push(o.slice(i,i + size));
Now, ar is:
[
['a', 'b'],
['c', 'd'],
['e', 'f']
]
No matter how you do it, there is alway going to be some looping. The compiler has to go through all the array elements to make the new array.
Speed Tests
So I'll create an array with this:
var l = 10000000, // The length
o = [], j;
for (j = 0; j < l; j += 1) o.push(j);
So that will make an array with l items now to test the speed:
var start = performance.now(),
size = 2, ar = [];
for (i = 0; i < o.length; i += size) ar.push(o.slice(i,i + size));
console.log(performance.now() - start);
Tests:
100 Thousand: 0.092909533996135 seconds
1 Million: 0.359059600101318 seconds
10 Million: 10.138852232019417 seconds
The 10 million time might surprise but if you have that big of an array you have bigger problems such as memory issues. And if this array is coming from a server you are probably going to be putting excessive strain on the server.