The Differences between ES6 Maps and Sets

preview_player
Показать описание
Maps are similar to Objects. Sets are similar to Arrays. Both provide you with Iterators which means that both can be used with a for...of loop.
Plain JavaScript Objects are not Iterable.
You can pass an Array directly into a Set using the constructor.
For Objects you need to loop through the properties and pass them to a Map one at a time.

Рекомендации по теме
Комментарии
Автор

The idea using Set to remove duplicate is eye-opening! Thank you very much, .

rotrose
Автор

Great explanation as always! Keep it up!

LeetCodeSimplified
Автор

Nice short video on the differences between Set/Array and Map/Object. I wanted to ask what are the purposes of using WeakMap and WeakSet? Only the advantage of garbage collection of the keys, am I right?

rungekutta
Автор

If you do an Array.from(names), you can convert the names Set back to an Array with duplicates removed. Quick way to eliminate duplicates from an Array.

rutwickgangurde
Автор

so what's the point of using maps if maps overwrite the previous data too?, i think maps will be different

muhamadizranovan
Автор

Thx bro how about map array function ist the same map object what you talk about I'm little confuse hh

ProgrammingWithOsku