Remove duplicates from array in JavaScript – the only right way

preview_player
Показать описание
There is an easy and idiomatic way to remove duplicates from an array in JavaScript. It is probably the shortest, too.

If you like my work, buy me a coffee ☕️:

It works when you want to remove duplicate numbers or duplicate strings from an array. To remove duplicate objects we have to use a different approach and I present two algorithms.

***

***

Music
Downtown Funk by Dj Quads
Рекомендации по теме
Комментарии
Автор

Thank you for saying what should I use. It would be great to show some examples

hofimastah
Автор

Další super video a díky za kod. Budu doufat, že jen tak neskončíš :-)

beemanik
Автор

"Only right way" depends from use case. Like if retaining original order is important or not. So shortest approach fails if ordering matters, but if speed is more relevant than ordering, then that approach maybe fastest (in theory, practice maybe different...).

talvisota