I want to split my array in half and save the results of that in another array, But without affecting the original.
So if I had [1,3,9,5] I would want to save it in a variable.
Then I would create new array and copy the initial one in it.
Then I would split that new array in half.
Meaning in the end I would have 2 array like this
initial [1,3,9,5] halved [1,3]
The problem is that initial one is also splitted and I get 2 array with each one holding half the values.
var initial = [1,3,9,5];
var half = initial;
half = half.splice(0, Math.floor(half.length / 2));
console.log(initial);
console.log(half);