Created
September 11, 2012 17:49
-
-
Save jamiehs/3700242 to your computer and use it in GitHub Desktop.
A simple way to copy an array in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myArray = new Array(1, 2, 3); | |
var copy = myArray.slice(); | |
// now I can change myArray[0] = 5; & it wont affect copy array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/q/8206988/24559