JS: Test Equality of Map Objects 📜
Test Map Equality
/* xah_map_equal(xmapA, xmapB) return true if two maps have the same keys and values. Keys are compared by triple equal. Values are compared by triple equal. JS: Map Equality 🚀 http://xahlee.info/js/js_map_equality.html Version: 2024-04-20 */ const xah_map_equal = (xmapA, xmapB) => { if (xmapA.size !== xmapB.size) return false; xmapA.forEach((vv, kk) => { if (!xmapB.has(kk)) return false; if (xmapB.get(kk) !== vv) return false; }); return true; }; // s------------------------------ const xx = new Map([[4, 44], [3, 33]]); const yy = new Map([[3, 33], [4, 44]]); console.assert(xah_map_equal(xx, yy) === true);