Javascript Set - Is It Better Than Array?

preview_player
Показать описание
Javascript Set vs Array what is better? Starting from Es6 we got Set which is an alternative to the array. Let's check if it is better and if we need to switch to it completely.

MOST POPULAR COURSES

FOLLOW ME

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

Thanks for this. I find Set very useful for removing duplicates in existing arrays.

gunman
Автор

In my experience I always go with arrays too because of exactly what you said, all of the super helpful methods on the array. I know sets have their place but it’s almost like I’m working in binary code compared to the array.

burningtree
Автор

I think word of "List" is much suitable for "[]"
classes like "Int8Array" are much more for word of "Array"

sinaebr
Автор

Sets work great if you need to store IDs (which need to be unique).

BrUSomania
Автор

The only benefit that set has is the unique value which is very helpful at some points because in arrays, it's very hard to do it, usually I have to loop through an array or create another comparison array just to do it. Set makes this problem much easier.

quanghungpham
Автор

the only real value of sets in my knowledge is to incorporate a reverse index algorithm and use sets for the reversed index of the objects, since you want in such case every value to be unique and store inside it the id of the object

MrKyriakos
Автор

Fyi: taking a breath between sentences is completely acceptable and can even be beneficial for communication clarity and overall delivery.

igorr