We, as software engineers, write so much code daily (maybe LLMs write that for us, nowadays), but do we really understand what’s going on under the hood?
That’s what hit me when I initiated a new Map() in my TypeScript code and thought, how does it actually solve my problem here? So here’s the blog, tadaa ✨
What is a HashMap or Map()?
A hashmap is a data structure to store key-value pairs, which is incredibly faster in retrieval, insertion, and deletion of data in O(1) time complexity.
const myMap = new Map<string, string>();
myMap.set("name", "rohit"); // stores < name:rohit >
myMap.has("name"); // true -> exists
myMap.get("name"); // rohit
myMap.delete("name"); // true -> deletedAmazing right? But what if I tell you it actually uses a special array to store the data?
Now I've got your attention there, let’s dive deep into it.
Read the full blog here.
