Skip to content

Instantly share code, notes, and snippets.

@jens1101
Created July 28, 2016 09:03
Show Gist options
  • Save jens1101/a9e4a8987c2fc698c2646dcfed6113c3 to your computer and use it in GitHub Desktop.
Save jens1101/a9e4a8987c2fc698c2646dcfed6113c3 to your computer and use it in GitHub Desktop.
Copy contents of one array into another without breaking references in JS
function arrayCopy(to, from) {
Array.prototype.push.apply(to, from);
}
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