Skip to content

Instantly share code, notes, and snippets.

@webdesignberlin
Forked from emilong/object-assign-arrays.js
Created October 16, 2016 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdesignberlin/fc73d5dff999196c1a7b49ce5667f758 to your computer and use it in GitHub Desktop.
Save webdesignberlin/fc73d5dff999196c1a7b49ce5667f758 to your computer and use it in GitHub Desktop.
const original = [0,1,2,3];
const copy = Object.assign([], original, { 2: 42 }); // [0,1,42,3]
console.log(original);
// [ 0, 1, 2, 3 ]
console.log(copy);
// [ 0, 1, 42, 3 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment