Answers for "merge 2 dictionaries with same keys javascript"

0

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);
Posted by: Guest on September-13-2021
0

javascript combine dictionaries

var a = {};
a['fruit'] = "apple";

var b = {};
b['vegetable'] = "carrot";

var food = Object.assign({}, a, b);

console.log(food);
Posted by: Guest on October-16-2020

Code answers related to "merge 2 dictionaries with same keys javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language