From the course: JavaScript: Maps and Sets
The Set object defined - JavaScript Tutorial
From the course: JavaScript: Maps and Sets
The Set object defined
- [Instructor] Like Map, sets were introduced with ES6, otherwise known as ES2015. The key feature of Set is that it is a collection of unique values, meaning you can not have duplicates of values in the set and those values can be anything. Sets can be a really powerful tool in your JavaScript programming. I'm sure you can think of some everyday examples where limiting a collection to unique values would be really helpful. Set comes with several methods as well as the size property. Many of these methods and their execution will be very similar to you after having learned about Map and WeakMap. You even initialize in the same manner. A set is initiated using new Set. Throughout this section, we will work through some examples together and give you a chance to try some things on your own. In the next lesson we'll get started with adding values to our set.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
The Set object defined57s
-
(Locked)
Add values to your set3m 17s
-
(Locked)
Does Set have your value?3m 9s
-
Get your set size2m 2s
-
(Locked)
Delete and clear values in your set2m 46s
-
(Locked)
Iterate over values in a set2m 45s
-
(Locked)
Iterate over a set with entries2m 25s
-
(Locked)
Iterate over your set with forEach2m 29s
-
(Locked)
Solution: Sets 12m 8s
-
(Locked)
Solution: Sets 22m 35s
-
-
-