0
Q:

HOW TO SPLIT AN ARRAY JAVASCRIPT

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); //split into chunks of two
5
array.splice(index, number, item1, ....., itemN)
1

var str = "How are you doing today?";

var res = str.split(" ");
 
7
// Returns new array from exising one
arr.slice(start, end);
3

New to Communities?

Join the community