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.

Map.prototype.set()

El método set() agrega un nuevo elemento al objeto Map con la llave y el valor especificado.

Syntax

myMap.set(llave, valor);

Parámetros

llave
Requerido. La llave del elemento a agregar al objeto Map.
valor
Requerido. El valor del elemento a agregar al objeto Map.

Valor de retorno

El objeto Map.

Ejemplos

Usando el método set

var miMapa = new Map();

// Agregar nuevos elementos al mapa
miMapa.set("bar", "foo");
miMapa.set(1, "foobar");

// Actualizar un elemento en el mapa
miMapa.set("bar", "baz");

Especificaciones

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Map.prototype.set' in that specification.
Standard Initial definition.
ECMAScript 2017 Draft (ECMA-262)
The definition of 'Map.prototype.set' in that specification.
Draft  

Compatibilidad con Navegadores

Caracterítica Chrome Firefox (Gecko) Internet Explorer Opera Safari
Soporte Básico 38 13.0 (13.0) 11 25 7.1
Caracterítica Android Chrome para Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Soporte Básico No support 38 13.0 (13.0) No support No support 8

Notas de compatibilidad

  • En versiones inferiores a Firefox 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30), Map.prototype.set retorna undefined y no es encadenable. Esto se ha reparado (bug 1031632). Este comportamiento también se encontró en Chrome/v8 (issue).

Véase también

Etiquetas y colaboradores del documento

 Colaboradores en esta página: guillermojmc
 Última actualización por: guillermojmc,