0

I have N objects and i want to merge them. In my case i'm sure there won't be any collisions.

I have:

var a = {'name': 'Freeman'}
var b = {'email': 'g.freeman@mesa.com'}

and i need :

c => {'name': 'Freeman', 'email': 'g.freeman@mesa.com'}

Is there a smart way to do that?

Thanks in advance!

Trivia: I want to merge these objects while a reduce job

Nick
  • 23
  • 4
  • Take a look at this [`link`](http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically) – Anand Jayabalan Feb 11 '15 at 15:09

1 Answers1

0

The link posted by Anand solved my issue. Thanks!

This does what i need:

for (var attrname in b) { a[attrname] = b[attrname]; }

source: How can I merge properties of two JavaScript objects dynamically?

Thanks Anand!

Community
  • 1
  • 1
Nick
  • 23
  • 4