Javascript - Map Data Type

About

Collection - Map (Associative arrays|Dictionary) in Javascript

Type

Object

Object as associative array.

let a = { "a":1, "b":1 };
a["b"]=2;
console.log(a);

Map

A map object has also been create to implement a more sophisticated map type.

Example:

keyValues= new Map();
keyValues.set("name","foo");
keyValues.set("color","blue");
for (const keyValue of keyValues){
    const [key, value] = keyValue 
    console.log("Key: "+key+", value: "+value);
}

values return an iterator

keyValues= new Map();
keyValues.set("name","foo");
keyValues.set("color","blue");

it = keyValues.values();
let result = it.next();
while (!result.done) {
 console.log(result.value); 
 result = it.next();
}

Documentation / Reference





Discover More
Javascript - Array

array in Javascript can contain any type of data. Different types of values can be stored within the same array Because arrays are special objects (as typeof implies), they can also have properties, including...
Javascript - Map function (Functional programming)

The functional programming function map in a Javascript context is only an array method as all functional programming javascript method. map With an Arrow function as argument Letters that we...



Share this page:
Follow us:
Task Runner