JavaScript Data Structures - 4 - Set

preview_player
Показать описание

📱 Follow Codevolution

JavaScript Data Structures
Data Structures in JavaScript
Set
Рекомендации по теме
Комментарии
Автор

Your style of speaking and explaining is so calming.

mansichauhan
Автор

You are Legend, helping developers community always, God bless you..

raj
Автор

That's amazing and your work Also. Please continue to js data structure.

Kingofmylife
Автор

1:20 unless I'm misunderstanding your terminology, I believe this is incorrect. Many other languages use sets that don't maintain insertion order, but in JavaScript sets are specified as maintaing insertion order, which can be confirmed by looping through it

Valyssi
Автор

Hey Vishwas, I think the insertion order is respected in Set, check below text that I pulled from MDN docs for Sets.

Set objects are collections of values. A value in the set may only occur once; it is unique in the set's collection. You can iterate through the elements of a set in insertion order. The insertion order corresponds to the order in which each element was inserted into the set by the add() method successfully (that is, there wasn't an identical element already in the set when add() was called).

rdrahuldhiman
Автор

Great content.

But, I have doubt can we do analogy and comparison between the array and set methods. Also what about the time complexity of the set methods?

susmitobhattacharyya
Автор

// create new set :
const set = new Set([1, 2, 3]);

// add new value :
set.add(5);
// you can add duplicate values :
set.add(5);

// list a set :
for (element of set) {
console.log(element);
}

// check if value exist :
console.log(set.has(4));

// delete a value of set :
set.delete(3);

// get the length of the set :
console.log("the size of the set is : ", set.size);

// clear a set :
set.clear();

//list using foreach :
set.forEach((element) => {
console.log("the value: ", element);
});

Ayoubmajid-uuyv
Автор

you said set are faster but didn't mention why?

yogeshvanzara
Автор

I hope you.
Can you create WhatsApp group?
Is it possible?

Kingofmylife