Created
October 2, 2017 18:34
-
-
Save csndra0504/68b5c5fe664570f656c9869b69c31d50 to your computer and use it in GitHub Desktop.
Composing JS Objects
This file contains 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 a = 'a'; | |
const b = 'b'; | |
const oA = { a }; // ES6 shortcut, same as const oA = { a: a }; | |
const oB = { b }; | |
//composing objects with ES6 spread operator | |
const c = {...oA, ...oB}; // { a: 'a', b: 'b' } | |
//composing objects with Object.assign() | |
const d = Object.assign({}, oA, oB); // { a: 'a', b: 'b' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment