JS: Convert Map to Object 🚀
JS: Convert Map Object to Object Object
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; }); // ssss--------------------------------------------------- // 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 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