0

I have two objects with the same structure and I want to concat them together using Javascript. Is there an easy way to do this?

var num = { '0': 0, '1': 0, '2': 0, '3': 0 };
var let = { 'A':'1', 'B':'2', 'C':'3' }
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
Hugolpz
  • 17,296
  • 26
  • 100
  • 187

1 Answers1

3

You can just use jQuery's .extend():

$.extend(num,let); // num will now be the merged object.

Note: every duplicate index will have the value it had in let

Yotam Omer
  • 15,310
  • 11
  • 62
  • 65