Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created August 28, 2017 03:43
Show Gist options
  • Select an option

  • Save prof3ssorSt3v3/22b080dcef57dc404184316b95ad0b8c to your computer and use it in GitHub Desktop.

Select an option

Save prof3ssorSt3v3/22b080dcef57dc404184316b95ad0b8c to your computer and use it in GitHub Desktop.
//Object.assign(target, sources... ) method
// used to copy objects OR
// to merge objects
let obj1 = {"arms":true, "armCount":2};
let obj2 = {"weapons":['missle launcher', 'reciprocating saw']};
let obj3 = {"canMove":true, "legs":0, "treads":2};
let arms = Object.assign({'hasHands':true, "arms": false}, obj1);
console.log( arms );
let robot = Object.assign({'hasHands':true, "arms": false}, obj1, obj2, obj3);
console.log(robot);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment