Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

WeakMap.prototype.set()

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 set() afegeix un nou element amb una key i un value especificats a un objecte WeakMap.

Sintaxi

wm.set(key, value);

Paràmetres

key
Necesari. La clau de l'element a afegir al objecte WeakMap.
value
Necesari. El valor de l'element a afegir a l'objecte WeakMap.

Valor de retorn

L'objecte WeakMap.

Exemples

Utilitzar el mètode set

var wm = new WeakMap();
var obj = {};

// Afegir nous elements al WeakMap
wm.set(obj, "foo").set(window, "bar"); // chainable

// Actualitzem un element en WeakMap
wm.set(obj, "baz");

Especificacions

Especificació Estat Comentaris
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'WeakMap.prototype.set' 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 Firefox 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30), WeakMap.prototype.set retornava undefined al no poder-se encadenar. Això s'ha arreglat  (errada 1031632). El comportament es pot trobar també a Chrome/v8 (problema).

Vegeu també

Document Tags and Contributors

 Contributors to this page: llue
 Last updated by: llue,