JS: Convert Map to Object 📜
Convert Map to Object
Deprecated
Here's a function to convert map object to data object.
/* xah_map_to_obj convert a map object to map, require just ES2015. This assumes the map key are string or symbol, because object key can only be these types. http://xahlee.info/js/js_Object.fromEntries.html Version: 2020-12-12 */ const xah_map_to_obj = ((xiterable) => { const xout = {}; for (let [k, v] of xiterable) xout[k] = v; return xout; }); // HHHH------------------------------ // test const xx = new Map([["a", 3], ["b", 4]]); const jj = xah_map_to_obj(xx); console.log(jj); // { a: 3, b: 4 }
JavaScript. Map Object
- JS: Map 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: Test Equality of Map Objects 📜
- 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 (class)
- JS: Map Constructor
- JS: Map.prototype