今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Iterate over a set with entries
- [Instructor] The next method we will discuss is entries. And it's another set method that returns an iterator. As we have learned, our set just contains values unlike map, which contains keys and values. And this entries method will return an array that contains the value twice. You may be wondering why the value is returned twice? And the reason is that it was done in order to keep the API similar to map. This is an interesting value to work with and you may find that it's not something you'll reach for very often, but it's still important to learn about how this method works. Just like the values method we will iterate over the available entries by using the next method, and then applying value. If we take a look at our invites example, we can see that this follows a very similar pattern and usage to the values method. We start by creating a new variable invite entries and set that equal to the invites with the…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
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 秒
-
-
-