今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Map contents with the entries method
- [Instructor] The entries method for Map works in a similar fashion to the keys and values methods that we just discussed. It also returns an Iterator and as you might expect it returns key-value pairs in an array. The syntax is also the same even down to applying the next method and accessing the value. Since this should be pretty familiar to you at this point, let's go ahead and look at our meals Map example. We first create a variable meal entries and set that equal to our meals Map with the entries method applied. To grab the first entry, we apply next and then grab the value. We can see here that this returns an array with our apple key and breakfast value. Now let's head to the code and try an example together. For this task, we want to determine the third set of entries in your Saturday Map. Let's start recreating a new variable that we'll call saturdayEntries. We set this equal to our Saturday Map with…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
The Map object defined1 分钟 23 秒
-
(已锁定)
Build your Map object with the set method4 分钟 41 秒
-
(已锁定)
Access a value with get3 分钟 51 秒
-
(已锁定)
Does the map have your key?3 分钟 4 秒
-
(已锁定)
Determine map size2 分钟 6 秒
-
(已锁定)
Remove key-value pairs with clear and delete4 分钟 23 秒
-
(已锁定)
Map: Keys and values methods5 分钟 44 秒
-
(已锁定)
Map contents with the entries method2 分钟 32 秒
-
(已锁定)
Loop over a map with forEach2 分钟 38 秒
-
(已锁定)
Group entries with groupBy3 分钟 22 秒
-
(已锁定)
Solution: Maps 12 分钟
-
(已锁定)
Solution: Maps 21 分钟 32 秒
-
-
-
-
-