Note: I assume this question has been asked a million times before but I didn't know what to search for.
var a = ['1','2','3'];
var b = ;
b = a;
a.length = 0;
a = b; will make both variables point to the same array / object, so you have to copy the array instead of just referencing it :
b = a.slice();
slice() method returns a new array sliced based on the parameters given, and if called without parameters it will return a new shallow copy of the entire array.