Created
July 28, 2016 09:03
-
-
Save jens1101/a9e4a8987c2fc698c2646dcfed6113c3 to your computer and use it in GitHub Desktop.
Copy contents of one array into another without breaking references in JS
This file contains hidden or 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
function arrayCopy(to, from) { | |
Array.prototype.push.apply(to, from); | |
} |
This file contains hidden or 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
function arrayCopy(to, from) { | |
to.push(...from); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment