JS: Map Filter 🚀
Here is a function that filters map object.
/* Return a new map where f(key,value) returns true. http://xahlee.info/js/js_map_filter.html Version 2018-04-13 */ const xah_map_filter = ((map_obj, f) => { const result = new Map(); for (let [k, v] of map_obj) if (f(k, v)) result.set(k, v); return result; }); // ssss--------------------------------------------------- // test const xx = new Map([[3, "n3"], [4, "n4"]]); console.log(xah_map_filter(xx, (k, v) => ((v === "n4") ? true : false))); // Map { 4 => "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