JavaScript ES6 Tutorial #10 - Sets

preview_player
Показать описание
Hey gang, in this ecmascript 6 tutorial, I'll introduce you to the new data type - sets. Sets in JavaScript allow us to store a set of unique values, and will not store any duplicate values.

----- COURSE LINKS:

---------------------------------------------------------------------------------------------
You can find more front-end development tutorials on CSS, HTML, JavaScript, jQuery, WordPress & more on the channel homepage...

========== JavaScript for Beginners Playlist ==========

============ CSS for Beginners Playlist =============

============== The Net Ninja =====================

================== Social Links ==================

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

holy shit dude, just a few days ago I was desperately searching for a solution to remove duplicates from a string, and now this super simple solution... thanks!

catalinim
Автор

Learing kungfu and JS together is amazing

lazyaussiensw
Автор

Can you also do a tutorial on Map(), please?

iFrancisDC
Автор

thank you for the informative and concise tutorial!

ninjarogue
Автор

Very helpful, thank you for the demonstration.

ILikeADoDaChaCha
Автор

fml, i literally just spent ages in making sure that i add multiples if there are and then add an item if it doesnt exist based on an "all item" array, it was such a hassle to loop through both and do all the checks, while i couldve just used fucking sets to solve it easily, LOL. ill watch more of your vids, easily understood this. +1

atviksordatviksord
Автор

Combining a bunch of examples:

const removeDuplicates(arr) => [...new Set(arr)];

justingolden
Автор

We can also convert Set object to an Array object, with Array.from
ninjas = Array.from(refinedNinjas);

mayankgangwal
Автор

How do i address a complex Object in Set?

hund
Автор

super easy explanation thank you so much :-)

sarvarsharapov
Автор

Hi Shaun, thanks for the great videos!
Is there a way to access one element from the set, like you can do it from an array with array[i]?
Also, you showed examples only with strings being the elements of the set, but it's worth noting that elements can be numbers and objects as well, I haven't tried booleans, but I believe that they can be elements of the set too.

Gruximillian
Автор

Hi, ninjafrend! What's the reason using a set() instead of a regular array, if you transform a set() to a regular array with the spread operator?

iFrancisDC
Автор

Yes tutorial, but the reality is different, we work day by day with array of objects and rare with simple array like in this example.

valikonen