Skip to content

Commit 3f36862

Browse files
committed
translate section Object.entries: Map from Object
1 parent 02664c5 commit 3f36862

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

1-js/05-data-types/07-map-set/article.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ map.set('1', 'str1')
100100
```
101101
````
102102
103-
## Iteração sobre o Mapa
103+
## Iteração sobre o Map
104104
105105
Para fazer um loop em um `map`, existem 3 métodos:
106106
@@ -146,12 +146,12 @@ recipeMap.forEach( (value, key, map) => {
146146
});
147147
```
148148
149-
## Object.entries: Map from Object
149+
## Object.entries: Map a partir de Objeto
150150
151-
When a `Map` is created, we can pass an array (or another iterable) with key/value pairs for initialization, like this:
151+
Quando um `Map` é criado, podemos passar um array (ou outro iterável) com pares chave/valor para inicialização, como este:
152152
153153
```js run
154-
// array of [key, value] pairs
154+
// array de pares [chave, valor]
155155
let map = new Map([
156156
['1', 'str1'],
157157
[1, 'num1'],
@@ -161,9 +161,9 @@ let map = new Map([
161161
alert( map.get('1') ); // str1
162162
```
163163
164-
If we have a plain object, and we'd like to create a `Map` from it, then we can use built-in method [Object.entries(obj)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) that returns an array of key/value pairs for an object exactly in that format.
164+
Se tivermos um objeto simples e gostaríamos de criar um `Map` a partir dele, podemos usar o método embutido [Object.entries(obj)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries), que retorna um array de pares chave/valor para um objeto exatamente nesse formato.
165165
166-
So we can create a map from an object like this:
166+
Portanto, podemos criar um mapa a partir de um objeto da seguinte forma:
167167
168168
```js run
169169
let obj = {
@@ -178,8 +178,7 @@ let map = new Map(Object.entries(obj));
178178
alert( map.get('name') ); // John
179179
```
180180
181-
Here, `Object.entries` returns the array of key/value pairs: `[ ["name","John"], ["age", 30] ]`. That's what `Map` needs.
182-
181+
Aqui, `Object.entries` retorna o array de pares chave/valor: `[ ["name","John"], ["age", 30] ]`. Isso é o que o `Map` precisa.
183182
184183
## Object.fromEntries: Object from Map
185184

0 commit comments

Comments
 (0)