JS: Map Substract 🚀
Substract Map
/* substract first map by second. return a new map. version 2024-04-19 */ const xah_map_substract = (Amap, Bmap) => { const xresult = new Map(); Amap.forEach((vv, kk) => { if (Bmap.has(kk) && (Bmap.get(kk) === vv)) { } else { xresult.set(kk, vv); } }); return xresult; }; const xxt = new Map([[3, "n3"], [4, "n4"], [5, "n4"]]); const xxh = new Map([[3, "n3"], [4, "n4"]]); console.log(xah_map_substract(xxt, xxh)); // Map(1) { 5 => "n4" }
JavaScript, Map Object
- JS: Map Object Tutorial
- JS: Difference, Object vs Map
- JS: Literal Expression for Map
- JS: Nested Map
- JS: Iterate Map Object
- JS: Convert Object to Map 🚀
- JS: Convert Map to Object 🚀
- JS: Map Equality 🚀
- JS: Map Filter 🚀
- JS: Swap Key Value of Map 🚀
- JS: Sort Map 🚀
- JS: Truncate Map 🚀
- JS: Map Substract 🚀
- JS: How Map Determines Uniqueness of Keys
- JS: Map Object
- JS: Map Constructor
- JS: Map.prototype