How To: JavaScript - Copy Array

The most common way to copy a JavaScript array is to use the slice() method. The result of the slice() method is a new array with the values from the "source" array.


var result = array1.slice(source);


var source = ["value1", "value2", "value3"];
var result = source.slice();
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License