Skip to content

Instantly share code, notes, and snippets.

@jamiehs
Created September 11, 2012 17:49
Show Gist options
  • Save jamiehs/3700242 to your computer and use it in GitHub Desktop.
Save jamiehs/3700242 to your computer and use it in GitHub Desktop.
A simple way to copy an array in JavaScript
var myArray = new Array(1, 2, 3);
var copy = myArray.slice();
// now I can change myArray[0] = 5; & it wont affect copy array
@jamiehs
Copy link
Author

jamiehs commented Sep 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment