课程: JavaScript: Maps and Sets

今天就学习课程吧!

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

Determine map size

Determine map size

- [Instructor] Unlike objects, Map comes with a built-in property to determine the size of your map. The size is the number of elements or key value pairs that are present in the map because it is a property you would simply apply size to your map without parentheses. We'll only use those parentheses when we're accessing maps methods. When we apply size to our map, a number will be returned indicating the number of key value pairs in our map. In our meals example, we can see just how easy it is to apply size and get the count of each of our elements. We know that this property is going to return a numerical value so we can set that to a variable and reuse it if we want. Now let's head over to the code and work on using the size property with our to-do list. First let's start by creating a new variable that we will call saturday size, const saturdaySize. All right. And then we're going to set this equal to our…

内容