课程: 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.

内容