Created
October 10, 2018 13:40
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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