string split to array javascript code example
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: javascript split
var arr = foo.split('');
console.log(arr);