I have two arrays: ArrayA and ArrayB. I need to copy ArrayA into ArrayB (as opposed to create a reference) and I've been using .splice(0)
but I noticed that it seems to removes the elements from the initial array.
In the console, when I run this code:
var ArrayA = [];
var ArrayB = [];
ArrayA.push(1);
ArrayA.push(2);
ArrayB = ArrayA.splice(0);
alert(ArrayA.length);
the alert shows 0. What am I doing wrong with .splice(0)
??
Thanks for your insight.