Hello Stranger !! I am Raiyan

Welcome to my blog

  • Software Engineer .

  • Opinions are of my own

This is test

JavaScript Basic Concepts of Map

The Map object in JavaScript is a collection of key-value pairs where the keys can be of any data type. It is similar to an object but provides more flexibility with key types. Key Features of Map Unique Keys: A Map object doesn’t allow duplicate keys. Each key is unique. Any Data Type for Keys: Unlike objects, a map’s keys can be of any type, even functions, objects, or primitive values. Order of Elements: The elements in a Map are ordered. They are iterated in the order of their insertion. Size Property: Map has a size property that returns the number of key-value pairs. Iterable: You can iterate through a Map’s keys, values, or entries using methods like keys(), values(), entries(), and for…of loops. Creating a Map const myMap = new Map(); myMap.set('name', 'John Doe'); myMap.set(42, 'The Answer'); myMap.set(true, 'boolean key'); console.log(myMap.get('name')); console.log(myMap.has(42)); // Output: true myMap.delete('name'); // Removes the key-value pair with the key 'name' for (let [key, value] of myMap) { console.log(key, value); } ...

August 12, 2024 · 3 min
This is test

Welcome to my blogs!

In this Space I will share my life lessons related to tech and in general. I aslo want to expand reach to other audience with this communication framework.

August 25, 2021 · 1 min