map a value from array of objects javascript code example

Example 1: typescript map list to new list of objects

var result = arr.map(person => ({ value: person.id, text: person.name }));
console.log(result)

Example 2: how to use the map method in javascript

const numbers = [1, 2, 3, 4, 5]; 

const bigNumbers = numbers.map(number => {
  return number * 10;
});

Example 3: 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!