|
@@ -14,7 +14,10 @@
|
|
|
* set() 往集合中添加键值对
|
|
|
* get() 获取集合中的键值
|
|
|
* has() 查找Map集合中是否包含所要查找的属性 返回值为布尔值
|
|
|
- * clear() 清空集合中的所有值 返回undefined
|
|
|
+ * clear() 清空集合中的所有值
|
|
|
+ * entries() 键值对
|
|
|
+ * keys() 键值对中的下标
|
|
|
+ * values() 键值对中的值
|
|
|
*
|
|
|
*/
|
|
|
let s1 = new Map();
|
|
@@ -45,10 +48,19 @@
|
|
|
arr2.set("school","US");
|
|
|
console.log(arr2);
|
|
|
|
|
|
- for(a of arr2.entries()) {
|
|
|
- console.log(a,'1');
|
|
|
+ for(let a of arr2.entries()) {
|
|
|
+ console.log(a,'entries');
|
|
|
}
|
|
|
- // console.log(arr2.entries());
|
|
|
+ for(let a of arr2.keys()) {
|
|
|
+ console.log(a,'keys');
|
|
|
+ }
|
|
|
+ for(let a of arr2.values()) {
|
|
|
+ console.log(a,'values');
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(arr2.keys().next().value)
|
|
|
+ console.log(arr2.entries().next().value)
|
|
|
+ console.log(arr2.values().next().value)
|
|
|
|
|
|
</script>
|
|
|
</body>
|