split an array into two based on a index in javascript
You can use Array@splice
to chop all elements after a specified index off the end of the array and return them:
x = ["a", "b", "c", "d", "e", "f", "g"];y = x.splice(3);console.log(x); // ["a", "b", "c"]console.log(y); // ["d", "e", "f", "g"]