javascript mab by field code example
Example 1: js map constructor
let myMap = new Map([
[1, 'one'], // [key, value]
[2, 'two'],
[3, 'three'],
]) // from MDN
Example 2: functions in map javascript
const map = new Map();
function foo() {
return "Hello World!";
}
map.set("foo", foo);
console.log(map.get("foo")()); // Output: "Hello World!