Minds
It is Recommended to practice while you learn
Map
Set

It is a collection of key-value

It is a collection of unique elements

Map is two-dimensional

The set is one dimensional

Values are accessed using keys

In-built methods are used to access values

Set

Destructuring Assignment is a JavaScript expression that allows to unpack values from arrays, or properties from objects, into distinct variables data can be extracted from arrays, objects, nested objects and assigning to variables. In Destructuring Assignment on the left-hand side defined that which value should be unpacked from the sourced variable.

// Defining array
let arr = [1,3,2,1,3,1,4,3,3,7,8]

// Creating Set And Passing Arr to Set
let num = new Set(arr);

//Printing set Num
console.log(num);
for (let i of num) {
console.log(i);
}

// Adding element in Set
num.add(6)
console.log(num);

// deleting element in Set
num.delete(6);
console.log(num.has(1));

Map

Maps are used to store data in key-value pairs where keys are used to uniquely identify an element and values contain the data associated with it.

// creating map
let newMap = new Map();

// printing map
console.log(map);

// Entering New Values
newMap.set("1","one")
newMap.set(2,"one")
newMap.set(true,"one")

console.log(newMap);

key : values // objects
key => values // maps fat arrow


Example :
let city = [
["india" , "gujrat"],
["indore" , "mp"],
["jalandar" , "punjab"],
];
let amap = new Map(city);
console.log(amap);
console.log(amap.get("jalandar"));