Skip to content

Commit 20e0078

Browse files
committed
translate section Iteration over Set
1 parent bc80b41 commit 20e0078

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,30 +272,30 @@ for (let user of set) {
272272
273273
A alternativa ao `Set` poderia ser um array de usuários e o código para verificar duplicatas em cada inserção usando [arr.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find). No entanto, o desempenho seria muito pior, porque esse método percorre todo o array verificando cada elemento. O `Set` é muito mais otimizado internamente para verificações de unicidade.
274274
275-
## Iteration over Set
275+
## Iteração sobre o Set
276276
277-
We can loop over a set either with `for..of` or using `forEach`:
277+
Podemos fazer um loop sobre um conjunto tanto com `for..of` quanto usando `forEach`:
278278
279279
```js run
280280
let set = new Set(["oranges", "apples", "bananas"]);
281281
282282
for (let value of set) alert(value);
283283
284-
// the same with forEach:
284+
// o mesmo com forEach:
285285
set.forEach((value, valueAgain, set) => {
286286
alert(value);
287287
});
288288
```
289289
290-
Note the funny thing. The callback function passed in `forEach` has 3 arguments: a `value`, then *the same value* `valueAgain`, and then the target object. Indeed, the same value appears in the arguments twice.
290+
Observe a coisa curiosa. A função de retorno de chamada passada no `forEach` tem 3 argumentos: um `value`, em seguida, *o mesmo valor* `valueAgain`, e depois o objeto de destino. Na verdade, o mesmo valor aparece nos argumentos duas vezes.
291291
292-
That's for compatibility with `Map` where the callback passed `forEach` has three arguments. Looks a bit strange, for sure. But this may help to replace `Map` with `Set` in certain cases with ease, and vice versa.
292+
Isso é para compatibilidade com o `Map`, onde a função de retorno de chamada passada no `forEach` tem três argumentos. Parece um pouco estranho, com certeza. Mas isso pode ajudar a substituir `Map` por `Set` em determinados casos com facilidade, e vice-versa.
293293
294-
The same methods `Map` has for iterators are also supported:
294+
Os mesmos métodos que o `Map` tem para iteradores também são suportados:
295295
296-
- [`set.keys()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/keys) -- returns an iterable object for values,
297-
- [`set.values()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values) -- same as `set.keys()`, for compatibility with `Map`,
298-
- [`set.entries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries) -- returns an iterable object for entries `[value, value]`, exists for compatibility with `Map`.
296+
- [`set.keys()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/keys) -- retorna um objeto iterável para valores,
297+
- [`set.values()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values) -- o mesmo que `set.keys()`, para compatibilidade com `Map`,
298+
- [`set.entries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries) -- retorna um objeto iterável para entradas `[valor, valor]`, existe para compatibilidade com `Map`.
299299
300300
## Summary
301301

0 commit comments

Comments
 (0)