This article needs an editorial review. How you can help.
This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.
La propietat WeakMap
.prototype
representa el prototip pel constructor WeakMap
.
Property attributes of WeakMap.prototype |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
Descripció
Les instantànies WeakMap
hereten de WeakMap.prototype
. Es pot utilitzar l'objecte prototip del constructor per afegir propietats o mètodes a totes les instàncies WeakMap.
WeakMap.prototype
és en si mateix només un objecte ordinari:
Object.prototype.toString.call(WeakMap.prototype); // "[object Object]"
Propietats
WeakMap.prototype.constructor
- Retorna la funció que ha creat un prototip de la instància. Aquesta és la funció
WeakMap
per defecte.
Mètodes
WeakMap.prototype.delete(key)
- Elimina qualsevol valor associat a
key
.WeakMap.prototype.has(key)
retornaràfalse
després d'això. WeakMap.prototype.get(key)
- Retorna el valor associat a
key
, oundefined
si no n'hi ha cap. WeakMap.prototype.has(key)
- Retorna un booleà afirmant si un valor s'ha associat o no a la
key
en l'objecteWeakMap
. WeakMap.prototype.set(key, value)
- Estableix el valor per la
key
en l'objecteWeakMap.
Retorna l'objecteWeakMap.
WeakMap.prototype.clear()
Elimina totes les parelles clau/valor de l'objecteWeakMap.
Vegeu que es posible implementar un objecteWeakMap
-like que tingui un mètode.clear()
per mitjà d'encapsular un objecteWeakMap
que no ho tingui (vegeu un exemple a la pàginaWeakMap
)
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'WeakMap.prototype' in that specification. |
Standard | Definició inicial |
Compatibilitat amb navegadors
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | 36 | 6.0 (6.0) | 11 | 23 | 7.1 |
Objecte ordinari | ? | 40 (40) | ? | ? | ? |
Característica | Android | Chrome per Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | Not supported | Not supported | 6.0 (6.0) | Not supported | Not supported | 8 |
Objecte ordinari | ? | ? | 40.0 (40) | ? | ? | ? |