var x = []; var y = [1,2,3,4]// see the change here var i; for (i = 0; i < y.length; ++i) { x.push(y[i]); // push every element here } console.log(x);