Is there any way to concat two (or more) Map Objects to a Map like array concat?
var map1 = new Map([['breakfast', 'meal'], ['dinner', 'meal']]);
var map2 = new Map([['launch', 'meal'], ['dinner', 'meal']]);
var concatenated = map1.concat(map2);
Is there any way to concat two (or more) Map Objects to a Map like array concat?
var map1 = new Map([['breakfast', 'meal'], ['dinner', 'meal']]);
var map2 = new Map([['launch', 'meal'], ['dinner', 'meal']]);
var concatenated = map1.concat(map2);
The simplest way I found was to convert maps to key value pair array
, concat them and finally create a new map from result:
var map1 = new Map([['breakfast', 'meal'], ['dinner', 'meal']]);
var map2 = new Map([['launch', 'meal'], ['dinner', 'meal']]);
var concatenated = new Map([...map1].concat([...map2]));