El mètode delete()
elimina l'element especificat d'un objecte WeakMap.
Sintaxi
wm.delete(key);
Parameters
- key
- Necessari. La clau de l'element a eliminar de l'objecte
WeakMap.
Valor de retorn
Retorna true
si un element en l'objecte WeakMap
s'ha eliminat satisfactòriament.
Exemples
Utilitzarel mètode delete
var wm = new WeakMap();
wm.set(window, "foo");
wm.delete(window); // Retorna true. Eliminat satisfactòriament
wm.has(window); // Retorna false. L'objecte window ja no es troba en el WeakMap.
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'WeakMap.prototype.delete' in that specification. |
Standard | Definició inicial |
Compatibilitat amb navegadors
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!
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | 36 | 6.0 (6.0) | 11 | 23 | 7.1 |
Característica | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Suport bàsic | No support | 6.0 (6.0) | No support | No support | 8 |
Notes específiques per a Firefox
- Abans de SpiderMonkey 38 (Firefox 38 / Thunderbird 38 / SeaMonkey 2.35), aquest mètode llançava un
TypeError
quan el paràmetrekey
no era un objecte. Aquest error s'ha arreglat en la versió 38 i posteriors al retornarfalse
segons l'últim estàndard ES6 (errada 1127827).