Skip to content

Instantly share code, notes, and snippets.

@developerruhul
Created October 10, 2018 13:40
Show Gist options
  • Select an option

  • Save developerruhul/442e7ffcc6896ca425b0dae731075761 to your computer and use it in GitHub Desktop.

Select an option

Save developerruhul/442e7ffcc6896ca425b0dae731075761 to your computer and use it in GitHub Desktop.
creating a third object from properties of other 2 objects by using es6 spread operator
const obj1 = {name: "miki", age: 32, gf: 32};
const obj2 = {fbId: "omgwhatanId", fbAge: 21, fbGf: 124};
// gf and fbGf are the properties we don't want
const {gf, ...obj1Properties} = obj1;
const {fbGf, ...obj2Properties} = obj2;
const obj3 = {...obj1Properties, ...obj2Properties};
console.log(obj3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment