From the course: JavaScript: Maps and Sets
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Same methods, different set - JavaScript Tutorial
From the course: JavaScript: Maps and Sets
Same methods, different set
- [Instructor] As we learned in the previous lesson a WeakSet has a few of the same methods as Set. These are add, has, and delete. At this point in the course, these methods and how they operate should be very familiar to you. We're going to review each method and then conclude this lesson by implementing each of them with WeakSet. The first method is add. We will use this method to construct our WeakSet. Remember with WeakSets, our values must be objects. You simply apply the add method to your WeakSet and pass in your value. Next is the has method. This method returns a boolean depending on whether or not your WeakSet has a specific value. You apply the method to your WeakSet and pass in the value that you're checking for. And last but not least, the delete method. This method will remove a value from your WeakSet based on the value you pass to the method when applied to your WeakSet. That was a quick review but I think…
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.