JS: Map Constructor
New in JS2015.
new Map()
- Create a empty map.
new Map(iterable)
- Create a map from values in Iterable Object.
const m = new Map(); // add new item m.set(1, "n1"); m.set(2, "n2"); console.log(m); // Map { 1 => 'n1', 2 => 'n2' }
Example of array to map:
// using nested array as literal expression for map const m = new Map([ [3, "n3"], [4, "n4"]]); console.log(m); // Map { 3 => 'n3', 4 => 'n4' }
Any Iterable Object can be used as argument.
Convert Object To/From Map
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