Last active
August 29, 2015 14:23
-
-
Save nwillems/d55494163dfccc08c185 to your computer and use it in GitHub Desktop.
Javascript Clone array
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
// Fire away with comments - I'd like to know faster or more compact | |
// or what-ever-measure-you-like solutions | |
function clone(a){ | |
return Array.apply(null, a); | |
} | |
// NOTE-to-Self: DONT EVER DO "arr.length--" it WILL mutate array! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to [http://jsperf.com/new-array-vs-splice-vs-slice/19] the fastest way is