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' }
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' }
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