The Map object defined
- [Instructor] Maps are an object type that was fairly recently introduced into JavaScript with ES2015. Object and Map are very similar, but they also have some key differences. Let's take a look at some of the ways that they're alike, and different to help you have a better understanding of how Map might fit into your code. Similar to Object, a Map contains key-value pairs. You can set the key-value pairs, get them, delete them, and check to see if a value is associated with a specific key. The Map object has slight differences that can make them extremely powerful and useful. Unlike an Object, a Map does not contain default keys. You have to set the keys in your Map. Additionally, a Map's keys are not limited to just a string or a symbol, they can be any value. Map also has a size property that allows you to easily determine the number of items your Map contains. One other important thing to keep in mind about Maps, is that you can not have duplicate keys in your key-value pairs. When you're ready to start using Map, you will use the constructor new Map to create a new Map object. Now that you have an idea of what makes Maps special, let's discuss how to create one and start utilizing the various methods and properties available on the Map object.
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
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 秒
-
-
-
-
-