Skip to content

Instantly share code, notes, and snippets.

@csndra0504
Created October 2, 2017 18:34
Show Gist options
  • Save csndra0504/68b5c5fe664570f656c9869b69c31d50 to your computer and use it in GitHub Desktop.
Save csndra0504/68b5c5fe664570f656c9869b69c31d50 to your computer and use it in GitHub Desktop.
Composing JS Objects
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