Map & Set: The Underrated Heroes of JavaScript
While writing the blog on Array method, I have came across some topics that are new to me and Map and Set are one of them. If you’d like to explore them too 👇 If You Don’t Know These Array Methods...

Source: DEV Community
While writing the blog on Array method, I have came across some topics that are new to me and Map and Set are one of them. If you’d like to explore them too 👇 If You Don’t Know These Array Methods, We Need to Talk. Kunal ・ Mar 3 #javascript #discuss #node #computerscience So in this blog we will cover : Topics to Cover Before Map & Set (The Old Way) What Map is Difference between Map and Object What Set is Difference between Set and Array When to use Map and Set Before Map & Set Before learning Set and Map , I tried doing things in the old ways using array and objects. For Map we do const data = {}; data["name"] = "Kunal"; data["age"] = 21; console.log(data["name"]); // Kunal For Set we do const arr = [1,2,2,3,3,5] const unique = [] for (let i = 0; i < arr.length; i++) { if(!unique.includes(arr[i])){ unique.push(arr[i]) } } console.log(unique); // [1,2,3,5] It worked but it required more code and wasn't clean or efficient. That's when i come across Set and Map. Map The Map