js array copy elements from index to index code example
Example: javascript copy array
var oldColors=["red","green","blue"];
var newColors = oldColors.slice(); //make a clone/copy of oldColors
var oldColors=["red","green","blue"];
var newColors = oldColors.slice(); //make a clone/copy of oldColors