0

Trying to do the following:

let obj = {
    user: 'john',
    foo: 'bar',
    someKey,
    ...KeyParse.explode(model.key) // returns an object
};

Is there any way to do the above? ie. spread the object returned from KeyParse.explode() into obj? So all the KeyParse.explode() keys would be populated into obj...

benhowdle89
  • 36,900
  • 69
  • 202
  • 331
  • Could you perhaps provide a link or a snippet that outlines the documentation for ``KeyParse.explode()``? I can't seem to find a reference to that anywhere. – Patrick Roberts Jun 16 '15 at 22:15
  • Perhaps `Object.assign` would work for your use case? – Jesse Kernaghan Jun 16 '15 at 22:17
  • I don't think ES6 is introducing anything specifically for that. I'd look at http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically – tcigrand Jun 16 '15 at 22:19
  • 1
    This is a proposed syntax for ES7: https://github.com/sebmarkbage/ecmascript-rest-spread You can use it with Babel if you want. It is commonly used in JSX. – loganfsmyth Jun 16 '15 at 22:25
  • 1
    @AnotherDev: Oh there is. Also have a look at [here](http://stackoverflow.com/q/29620686/1048572) – Bergi Jun 16 '15 at 22:27
  • Thanks, I stand corrected. – tcigrand Jun 16 '15 at 22:29

0 Answers0