Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

merge 2 dictionaries with same keys javascript

const target = { a: [1], b: [2] };
const source = { a: [2], c: [5] };

const returnedTarget = Object.assign(target, source);

for(var date in source)
target[date] = [...target[date] || [],...source[date]]

console.log(target);
 
PREVIOUS NEXT
Tagged: #merge #dictionaries #keys #javascript
ADD COMMENT
Topic
Name
4+7 =