Psiloc
0
Q:

map method

array.map((item) => {
  return item * 2
} // an example that will map through a a list of items and return a new array with the item multiplied by 2
21
const map = new Map();

function foo() {
 return "Hello World!"; 
}

map.set("foo", foo);

console.log(map.get("foo")()); // Output: "Hello World!
3
let myMap = new Map()

let keyString = 'a string'
let keyObj    = {}
// setting the values
myMap.set(keyString, "value associated with 'a string'")
myMap.set(keyObj, 'value associated with keyObj')
myMap.set(keyFunc, 'value associated with keyFunc')
myMap.size              // 3
// getting the values
myMap.get(keyString)    // "value associated with 'a string'"
myMap.get(keyObj)       // "value associated with keyObj"
myMap.get(keyFunc)      // "value associated with keyFunc"
3
array.map( item => item.id )

array2.map( item => item.toString() )

array2.map( item => item * 3 )

// this will apply a transformation to all elements of an array
// "" item => something "" is the transformation (function)
0
var yourArray= yourArray.map(Number);
-1

Tags

Related

New to Communities?

Join the community