copy array in javascript Mar 7, 2010 • Fred Yang var x = [1, 2]; var y = x.slice(0); y[0] = 100; //y --> [100, 2] alert(x[0]); //1 The new copy evolve independently of the old copy. Please enable JavaScript to view the comments powered by Disqus.