I have following JavaScript objects (new_object and old_object):
new_object:
0300 : ["295", "293", "298"],
0800 : ["293", "298"],
0930 : ["295"],
1130 : ["297", "293", "298"],
1230 : ["295"]
old_object:
0300 : ["297"],
0800 : ["297"],
0930 : ["293"],
I want to merge them so that final object would be like
0300 : ["295", "293", "298", "297"],
0800 : ["293", "298", "297"],
0930 : ["295", "298", "293"],
1130 : ["297", "293", "298"],
1230 : ["295", "298"]
I tried new_object['0300'].push with each loop but its not working
How could I merge JavaScript objects ? Are there any best practices?
0930key in the result contain298? Also, be careful with your keys: if you mean them as strings, fine, but0300is an octal constant which means192.