课程: JavaScript: Maps and Sets

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Map contents with the entries method

Map contents with the entries method - JavaScript教程

课程: JavaScript: Maps and Sets

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…

内容