今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Iterate over your set with forEach
- [Instructor] Our final lesson on sets will cover the ForEach method. At this point, you should be an expert on ForEach. This method will work as expected with a few minor differences in the callback function. The ForEach method provides a callback function for each value in the set. Just like map, the ForEach method with set accepts four optional parameters. For the sake of this course, I'll only be focusing on three: value1, value2, and set. As we mentioned in the last lesson, the APIs for map and set are the same. Because sets only contains values, both value1 and value2 will be the same. The set parameter represents the entire set that is being looped over. If we take a look at our invite set, we're looping over our set with ForEach. And if the value starts with the letter J, we're going to log it out. Starts with is a JavaScript string method that comes in handy in this particular example. Now let's head to our…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
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 秒
-
-
-