var myArray = [1,2,3,4,5,6,7,8,9];
var halfLength = Math.ceil(myArray.length / 2);
var firstHalf = myArray.splice(0,halfLength);
console.log(myArray); // SECOND HLAF
[1, 2, 3, 4, 5]
[6, 7, 8, 9]
If the number of elements in an array are even, array will be divided equally. However, if the number of elements in an array are odd, and Math.ceil is taken then first half of the array will get an extra element. If Math.floor is taken then the second half will have that extra element.