diff options
author | Raphael Barbosa Rodrigues <raphaelbarbosa.rodrigues@gmail.com> | 2021-10-19 08:38:36 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 08:38:36 -0300 |
commit | b53e739a002f580203dfdf67ed4a01327852f0e9 (patch) | |
tree | 65175cda9926a460ce61196fdc3f8582a4a510c8 /files/pt-br/web/javascript/reference/global_objects/map/set/index.md | |
parent | 03633da695fbaca2c8fc8fe6d25dbbb318a0ce0b (diff) | |
download | translated-content-b53e739a002f580203dfdf67ed4a01327852f0e9.tar.gz translated-content-b53e739a002f580203dfdf67ed4a01327852f0e9.tar.bz2 translated-content-b53e739a002f580203dfdf67ed4a01327852f0e9.zip |
[pt-BR] Translating Global_Objects/Array/Map (#2351)
* Translating the main content of /Web/JavaScript/Reference/Global_Objects/Map to pt-BR
* Translating the secondary content of /Web/JavaScript/Reference/Global_Objects/Map to pt-BR
* fix(pt-BR): translating missing texts on Global_Objects/Map
* fix(pt-BR): adding empty space in Global_Objects/Map/entries.md to avoid tests error
* fix(pt-BR): removing empty space on entries file to avoid test error
* Delete index.md
* fix(pt-BR): adjusting translation on global_objects/map
* feat(pt-BR): translating entries on global_objetcts/Map
* feat(pt-BR): translating entries on global_objetcts/Map
Diffstat (limited to 'files/pt-br/web/javascript/reference/global_objects/map/set/index.md')
-rw-r--r-- | files/pt-br/web/javascript/reference/global_objects/map/set/index.md | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/files/pt-br/web/javascript/reference/global_objects/map/set/index.md b/files/pt-br/web/javascript/reference/global_objects/map/set/index.md new file mode 100644 index 0000000000..b152f42f4d --- /dev/null +++ b/files/pt-br/web/javascript/reference/global_objects/map/set/index.md @@ -0,0 +1,74 @@ +--- +title: Map.prototype.set() +slug: Web/JavaScript/Reference/Global_Objects/Map/set +tags: + - ECMAScript 2015 + - JavaScript + - Map + - Method + - Prototype + - Reference +browser-compat: javascript.builtins.Map.set +--- +{{JSRef}} + +O método **`set()`** adiciona ou atualiza um elemento com a chave especificada e um valor do objeto `Map`. + +{{EmbedInteractiveExample("pages/js/map-prototype-set.html")}} + +## Sintaxe + +```js +set(key, value) +``` + +### Parâmetros + +- `key` + - : A chave do elemento que será adicionado ao objeto `Map`. +- `value` + - : O valor do elemento que será adicionado ao objeto `Map`. + +### Valor retornado + +O objeto `Map`. + +## Exemplos + +### Usando o set() + +```js +let myMap = new Map() + +// Adiciona um elemento ao map +myMap.set('bar', 'foo') +myMap.set(1, 'foobar') + +// Atualiza um elemento no map +myMap.set('bar', 'baz') +``` + +### Usando o `set` de forma encadeada + +Já que o método `set()` retorna o mesmo objeto `Map`, você pode encadear a chamada do método como abaixo: + +```js +// Adiciona novos elementos ao map de forma encadeada. +myMap.set('bar', 'foo') + .set(1, 'foobar') + .set(2, 'baz'); +``` + +## Especificações + +{{Specifications}} + +## Compatibilidade com navegadores + +{{Compat}} + +## Veja também + +- {{jsxref("Map")}} +- {{jsxref("Map.prototype.get()")}} +- {{jsxref("Map.prototype.has()")}} |