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
  • 857,932
  • 118
  • 1,152
  • 1,264
Hugolpz
  • 16,007
  • 25
  • 91
  • 183

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
  • 14,836
  • 11
  • 58
  • 62