Javascript: create a copy of an array using slice(); - Stack …
https://stackoverflow.com/questions/52121005/javascript-create-a-copy-of-an-array-using-slice
Javascript: create a copy of an array using slice (); I need to create a copy of an array so that I can do modification on one array without affecting the other. var a = [ [1], [2], [3]]; var b = a.slice (0); b [1].push (100); b // [ [1], [2, 100], [3]]; a // expect: [ [1], [2], [3]]; , actual: [ [1], [2, 100], [3]]; but this puts all [1], [2], [3] to index 0 in the new array.
DA: 37 PA: 40 MOZ Rank: 66