今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Delete and clear values in your set
- [Instructor] In order to delete and clear values from a set, we can reach for methods of the same name. The first method is delete. This will remove a single value from a set. In order to delete a value from a set, you will simply apply the delete method to your set and pass in the value that you'd like to delete. It's that simple and almost identical to what we did with maps. Moving onto the clear method, this method will remove all of the values from a set. You may remember this from our maps discussion as well. To clear your set, you simply apply the clear method to your existing set. It does not take any arguments. If you want to check that your set was cleared successfully, you could use the size property to make sure it's back to zero. Let's take a look at our invites example and see these methods in action. We decided that we no longer want to invite Jane to our party, so we decide to delete her invite.…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
The Set object defined57 秒
-
(已锁定)
Add values to your set3 分钟 17 秒
-
(已锁定)
Does Set have your value?3 分钟 9 秒
-
Get your set size2 分钟 2 秒
-
(已锁定)
Delete and clear values in your set2 分钟 46 秒
-
(已锁定)
Iterate over values in a set2 分钟 45 秒
-
(已锁定)
Iterate over a set with entries2 分钟 25 秒
-
(已锁定)
Iterate over your set with forEach2 分钟 29 秒
-
(已锁定)
Solution: Sets 12 分钟 8 秒
-
(已锁定)
Solution: Sets 22 分钟 35 秒
-
-
-