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.
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
| 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 | Not supported | 6.0 (6.0) | Not supported | Not supported | 8 |
Notes específiques per a Firefox
- Abans de SpiderMonkey 38 (Firefox 38 / Thunderbird 38 / SeaMonkey 2.35), aquest mètode llançava un
TypeErrorquan el paràmetrekeyno era un objecte. Aquest error s'ha arreglat en la versió 38 i posteriors al retornarfalsesegons l'últim estàndard ES6 (errada 1127827).