Skip to content

Instantly share code, notes, and snippets.

@btg5679
Last active July 15, 2017 00:52
Show Gist options
  • Save btg5679/5362f30f3cba086333c5a703bdc415de to your computer and use it in GitHub Desktop.
Save btg5679/5362f30f3cba086333c5a703bdc415de to your computer and use it in GitHub Desktop.
var a = { name: 'Pilsner', abv: 5.4 };// Remains untouched
var b = Object.assign({}, a, {abv: 6.7})// b = { name: 'Pilsner', abv: 6.7 }}
var a = [0, 1, 2]// Remains untouched
var b = a.concat(3)// b = [0, 1, 2, 3]
var c = a.filter((val) => != 2)// c = [0, 1, 3]
var a = {name: 'Dave Matthews', songs: [0, 1, 2]}// Remains untouched
var b = Object.assign({}, a, {name: 'Jack Johnson'});// b = {name: 'Jack Johnson', songs: [0, 1, 2]}
b.songs = a.songs.concat(3);// b = {name: 'Jack Johnson', things: [0, 1, 2, 3]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment