Hashmap in Javascript

Something like a Hashmap can be easily done in javascript as following

let map = {};

// add values to the map
map['key1'] = 1;
map['key1'] = 2;
map['key1'] = 3;

// iterate map
for (let key in map) {
    if (map.hasOwnProperty(key)) {
        let d = map[key];
        console.log(d);

    }
}

Leave A Comment

Your email address will not be published.