Set vs WeakSet vs Array in Javascript

preview_player
Показать описание
Learn about the key differences between Set, WeakSet and Arrays and when to use what

Read Article Version;

playlist:

follow @:

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

There’s one more super important difference. Arrays use linear lookup while sets just use hash lookup. Meaning that you need to check every single item in an array in the worst case scenario. In a set, you just basically look in one location. So, it’s orders of magnitude faster when you need to do a lot of lookups in a long array/set.

iuhuoqp
Автор

Hey! Thank you for the clear explanation! But in 2:08, isn't shift() should be in Remove operations, and unshift() should be in add operations?

myogatinovi