9951 explained code solutions for 126 technologies


javascriptHow to copy array values (instead of variable reference)


var arr = [1, 2, 3, 4, 5];
var copy = arr.slice();ctrl + c
var arr

declare test array to copy values from

copy

will contain new array with all values from arr

arr.slice()

will return all values from arr