Skip to content

Instantly share code, notes, and snippets.

@amrelarabi
Created December 12, 2021 08:08
Show Gist options
  • Save amrelarabi/fe64d89d026983f804836fdd65d85731 to your computer and use it in GitHub Desktop.
Save amrelarabi/fe64d89d026983f804836fdd65d85731 to your computer and use it in GitHub Desktop.
let oldArray = [1, 2, 3];
let newArray = [...oldArray, 4, 5];
// [ 1, 2, 3 ]
console.log(oldArray);
[ 1, 2, 3, 4, 5 ]
console.log(newArray);
oldArray.pop();
[ 1, 2 ]
console.log(oldArray);
[ 1, 2, 3, 4, 5 ]
console.log(newArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment