merge 2 dictionaries with same keys javascript

Solutions on MaxInterview for merge 2 dictionaries with same keys javascript by the best coders in the world

showing results for - "merge 2 dictionaries with same keys javascript"
Trevor
12 Jun 2017
1const target = { a: [1], b: [2] };
2const source = { a: [2], c: [5] };
3
4const returnedTarget = Object.assign(target, source);
5
6for(var date in source)
7target[date] = [...target[date] || [],...source[date]]
8
9console.log(target);
Eleonora
06 Oct 2018
1var a = {};
2a['fruit'] = "apple";
3
4var b = {};
5b['vegetable'] = "carrot";
6
7var food = Object.assign({}, a, b);
8
9console.log(food);
queries leading to this page
javascript combine dictionariesjs add two dictionariesjs expand dictionary into dictioanrycombine two dictionaries nodejscombine all dictionary in javascriptadd two dictionaries javascriptjavascript union dictsjavascript dictionary mergecombine object and dictionary javascripthow to merge two dictionaries in javascript with concat dict jsjavascript merge two arrays with same key valuemerge array with same key javascriptmerge two dicts jscombine dictionaries javascriptjs merge two dictionariesmerge two different dicts jscombine dict javascriptjavascript merge 2 dictionariesjavascript add two dictionaries with mathhow to join dictionaries in javascriptnodejs merge dictionaryjs merge dictionariesjavascript combine dicjs join dictscombine two dictionaries javascriptjavascript merge two dictionariesmerge 2 dictionaries with same keys javascriptconcat two dictionary jsjs combine dictionariesmerge a dictionary into another dictionary javascriptmerge dicts javsacriptcombine two arrays in dictionaries javascriptmerge 2 dictionaries in javascript combining dictionaries in javascriptcombine 2 dicts jsjavascript concat dictionaryconcatenate two dictionaries javascriptcombine all values fo dictionary in javascriptjoin two dicts jsjavascript merge ditionariesjavascript add two dictionariesconcat dictionary to array javascriptcalculate two dictionaries value in one typescriptmerge 2 dict jsjavascript combine two dictionariesjavascript merge list of dictionariesjavascript concatenate dictionariesconcat dictionary javascriptjoin two dictionaries javascripthow to merge two dictionaries in javascriptwhich method is used to merge the data in dictionary in javascriptjavascript merge dictionariesjs combine to dictsjs combine two dictionarymerge data in same key jsjavascript combine two dictinoariesjavascript how to combine two arrays into a dictionaryconcat dictionary jsjavascript merge two dictjavascript join dictionary valuescombile 2 dict javascripthow to merge two arrays in javascript key value pairsjavascript add 2 dictionariesmerge array with same key and merge value javascriptmerge two arrays with same keys javascriptfunction to merge two dictionaries in javascript two different array merge key value pair jsjavascript dictionary concatjavascript merge same keys value of 2 arrays of objectmerge dictionaries javascriptdictionary object js mergehow to merge two dicts in jsmerge 2 dicts jsmerge 2 dictionaries with same keys javascript