Map.prototype 属性表示 Map构造函数的原型对象。
Map.prototype 属性的属性特性: |
|
|---|---|
| writable | false |
| enumerable | false |
| configurable | false |
描述
Map.prototype。你可以使用这个构造函数的原型对象来给所有的Map实例添加属性或者方法。
属性
-
Map.prototype.constructor -
返回一个函数,它创建了实例的原型。默认是
Map函数。 -
Map.prototype.size - 返回Map对象的键/值对的数量。
方法
-
Map.prototype.clear() - 移除Map对象的所有键/值对 。
-
Map.prototype.delete(key) -
如果
Map对象中存在该元素,则移除它并返回true;否则如果该元素不存在则返回false -
Map.prototype.entries() -
返回一个新的
Iterator对象,它按插入顺序包含了Map对象中每个元素的[key, value]数组。 -
Map.prototype.forEach(callbackFn[, thisArg]) -
按插入顺序,为
Map对象里的每一键值对调用一次callbackFn函数。如果为forEach提供了thisArg,它将在每次回调中作为this值。 -
Map.prototype.get(key) - 返回键对应的值,如果不存在,则返回undefined。
-
Map.prototype.has(key) - 返回一个布尔值,表示Map实例是否包含键对应的值。
-
Map.prototype.keys() -
返回一个新的
Iterator对象, 它按插入顺序包含了Map对象中每个元素的 键 。 -
Map.prototype.set(key, value) - 设置Map对象中键的值。返回该Map对象。
-
Map.prototype.values() -
返回一个新的
Iterator对象,它按插入顺序包含了Map对象中每个元素的 值 。 -
Map.prototype[@@iterator]() -
返回一个新的
Iterator对象,它按插入顺序包含了Map对象中每个元素的[key, value]数组。
规范
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) Map.prototype |
Standard | Initial definition. |
| ECMAScript Latest Draft (ECMA-262) Map.prototype |
Draft |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains.
Find out how you can help!
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 38 | 13 (13) | 11 | 25 | 7.1 |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | 未实现 | 38 | 13.0 (13) | 未实现 | 未实现 | 8 |