map return new object javascript code example
Example 1: 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!
Example 2: map a property from array of objects javascript
var result = objArray.map(function(a) {return a.foo;});