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 Object to Object 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