Example 1: javascript split array into chuncks of
function splitArrayIntoChunksOfLen(arr, len) {
var chunks = [], i = 0, n = arr.length;
while (i < n) {
chunks.push(arr.slice(i, i += len));
}
return chunks;
}
var alphabet=['a','b','c','d','e','f'];
var alphabetPairs=splitArrayIntoChunksOfLen(alphabet,2);
Example 2: javascript explode
var str = "Well, how, are , we , doing, today";
var res = str.split(",");
Example 3: string split javascript
var myString = "An,array,in,a,string,separated,by,a,comma";
var myArray = myString.split(",");
Example 4: javascript split
var arr = foo.split('');
console.log(arr);
Example 5: js string to array
var myString = 'no,u';
var MyArray = myString.split(',');
Example 6: javascript turn string into array
var fruits = 'apple, orange, pear, banana, raspberry, peach';
var ar = fruits.split(', ');
console.log( ar );