From the course: JavaScript: Maps and Sets
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Map: Keys and values methods - JavaScript Tutorial
From the course: JavaScript: Maps and Sets
Map: Keys and values methods
- [Instructor] Before we discuss our next two methods, keys and values, we're going to quickly review what an iterator is and how it relates to our Map. In JavaScript, we iterate over collections frequently using array methods like Map or for each. An iterator is defined by the MDN documentation as an object which defines a sequence, and potentially returns a value upon its termination. The next method is applied to the iterator and it has two properties, value and done. With our Map, some of its methods return iterators which allow us to cycle through keys and values in the order that they were inserted within our Map. Let's start with the keys method. It returns an iterator object that allows us to cycle through all of the keys found in our Map. It's likely that you would utilize this method by creating a new variable and setting it equal to your Map and then apply the keys method. Then, when you wanted to iterate over the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
The Map object defined1m 23s
-
(Locked)
Build your Map object with the set method4m 41s
-
(Locked)
Access a value with get3m 51s
-
(Locked)
Does the map have your key?3m 4s
-
(Locked)
Determine map size2m 6s
-
(Locked)
Remove key-value pairs with clear and delete4m 23s
-
(Locked)
Map: Keys and values methods5m 44s
-
(Locked)
Map contents with the entries method2m 32s
-
(Locked)
Loop over a map with forEach2m 38s
-
(Locked)
Group entries with groupBy3m 22s
-
(Locked)
Solution: Maps 12m
-
(Locked)
Solution: Maps 21m 32s
-
-
-
-
-