今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Add values to your set
- [Instructor] In order to construct your new set, you will need to reach for the method, add. The add method adds a new value to your set upending the specified value to the end of your object. In order to add values, we simply apply the set method to our existing set and pass in the value. This method can also be changed which will save you some room in your code. Let's move on to an example and see add in action. As we did with maps, we will revisit the same example with sets as we learn each of its methods in property. For our sets example, let's imagine that we're planning a surprise birthday party for our friend. We're going to utilize a set because we want to make sure we don't have any duplicate email addresses when we send out our invitations. Let's start by creating a new set, invites. Once created, let's add our emails to the set using the add method. We're going to save ourselves some typing and chain…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
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 秒
-
-
-