var map = new Map();
map.set('spec', '2015');
map.set('year', '2015');
// use `.get()` to retrieve items
console.log(map.get('spec')); // 2015
// iteration
for (var [key, value] of map) {
console.log(key + ': ' + value);
}
// helper functions
map.entries(); // Gives you all the entries in map
map.keys(); // Gives you all the keys in map
map.values(); // Gets you the values stored in map
map.has(keyName); // Checks if a map has specified key or not
map.delete(keyName); // Replaces the value having the provided key
map.size; // Gives you the size of map
map.clear(); // Clears all the collection
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.