Removing items from a set

To remove an item from a set, we can use the remove() method. When we use this method, we input the item we want to remove in the parentheses. Let's remove Winter Solider from Craig's movie list:

craigsFavMovieSet.remove("Winter Solider") 

Your code should now look like this:

If you tried to remove more than a single item from a set (for instance, all of the items), then you can use the removeAll() method or give it an empty array literal:

craigsFavMovieSet.removeAll() 
gabesFavMovieSet = []

Your code should now look like this:

Now, both sets are empty.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.95.244