GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — WeakMap and WeakSet by diogoosz · Pull Request #463 · javascript-tutorial/pt.javascript.info

Conversation

@diogoosz

@diogoosz diogoosz commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Tradução do artigo "WeakMap and WeakSet" para o português, incluindo os dois exercícios.

Conforme comentado na #1.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@diogoosz
Translate 'WeakMap and WeakSet' article to Portuguese
0220a5c
@CLAassistant

CLAassistant commented Nov 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gabifs
gabifs reviewed Nov 7, 2026
View reviewed changes

@gabifs gabifs left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oi @diogoosz, obrigado pela tradução! Ficou bem fluida no geral. Deixei algumas sugestões, a maioria sobre termos em inglês que poderiam ser traduzidos e um ajuste de sentido no enunciado da primeira tarefa. Nada que bloqueie, mas acho que deixam o texto mais consistente.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 1-js/05-data-types/08-weakmap-weakset/article.md Outdated
// therefore it won't be garbage-collected
// we can get it as array[0]
// o objeto anteriormente referenciado por john está guardado dentro do array,
// por isso ele não será coletado pelo garbage collector

@gabifs gabifs Nov 7, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"garbage collector" aparece em várias partes deste artigo (linhas 36, 41, 59, 104, 116, 125, 152, 213, 244 e 291) e também em 02-recipients-when-read/task.md:19. As diretrizes de tradução pedem para evitar palavras estrangeiras quando existe um termo em português, e o capítulo linkado no começo do artigo (info:garbage-collection) se chama "Coleta de lixo". Que tal usar "coletor de lixo"?

Suggested change
// por isso ele não será coletado pelo garbage collector
// por isso ele não será removido pelo coletor de lixo

Nas outras ocorrências, "coletado pelo coletor de lixo" fica repetitivo; "removido pela coleta de lixo" ou "removido da memória pela coleta de lixo" soam mais naturais.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 1-js/05-data-types/08-weakmap-weakset/article.md Outdated
```

Now, if we use an object as the key in it, and there are no other references to that object -- it will be removed from memory (and from the map) automatically.
Agora, se usamos um objeto como chave nele, e não existe mais nenhuma outra referência a esse objeto -- ele será removido da memória (e do map) automaticamente.

@gabifs gabifs Nov 7, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"map" e "set" aparecem como substantivos comuns no texto (linhas 80, 93, 125 e 252, e 01-recipients-read/solution.md:30). Sugiro usar o nome do tipo em código ou traduzir:

Suggested change
Agora, se usamos um objeto como chave nele, e não existe mais nenhuma outra referência a esse objeto -- ele será removido da memória (e do map) automaticamente.
Agora, se usamos um objeto como chave nele, e não existe mais nenhuma outra referência a esse objeto -- ele será removido da memória (e do `WeakMap`) automaticamente.
  • L93: "apagado do map" → "removido do WeakMap"
  • L125: "guardada em um map" → "guardada em um Map"
  • L252: "existe no set" → "existe no WeakSet"
  • solution.md L30: "as que estão no set" → "as que estão no WeakSet"

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 1-js/05-data-types/08-weakmap-weakset/article.md Outdated
## Caso de uso: cache

Another common example is caching. We can store ("cache") results from a function, so that future calls on the same object can reuse it.
Outro exemplo comum é o cache. Podemos guardar ("cachear") os resultados de uma função, para que chamadas futuras sobre o mesmo objeto possam reaproveitá-los.

@gabifs gabifs Nov 7, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"cachear" é um anglicismo. Sugestão:

Suggested change
Outro exemplo comum é o cache. Podemos guardar ("cachear") os resultados de uma função, para que chamadas futuras sobre o mesmo objeto possam reaproveitá-los.
Outro exemplo comum é o cache. Podemos guardar em cache os resultados de uma função, para que chamadas futuras sobre o mesmo objeto possam reaproveitá-los.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 1-js/05-data-types/08-weakmap-weakset/article.md Outdated
- Like `Set`, it supports [`add`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Weakset/add), [`has`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Weakset/has) and [`delete`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Weakset/delete), but not `size`, `keys()` and no iterations.
- É análogo ao `Set`, mas só podemos adicionar objetos ao `WeakSet` (não primitivos).
- Um objeto existe no set enquanto for alcançável de algum outro lugar.
- Assim como o `Set`, ele suporta [`add`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Weakset/add), [`has`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Weakset/has) e [`delete`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Weakset/delete), mas não `size`, `keys()`, e não há iterações.

@gabifs gabifs Nov 7, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Opcional) Detalhe que já vem do original: os links dos métodos do WeakSet usam Weakset (com "s" minúsculo) no caminho. Funciona por causa do redirecionamento do MDN, mas já que a linha foi mexida, dá pra corrigir para Global_Objects/WeakSet/add, /has e /delete. Se quiser, também dá pra apontar para pt-BR em vez de en-US, mas o repositório usa os dois, então fica a seu critério.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 1-js/05-data-types/08-weakmap-weakset/01-recipients-read/task.md Outdated
Seu código pode acessá-lo, mas as mensagens são gerenciadas pelo código de outra pessoa. Mensagens novas são adicionadas, as antigas são removidas regularmente por esse código, e você não sabe os momentos exatos em que isso acontece.

Now, which data structure could you use to store information about whether the message "has been read"? The structure must be well-suited to give the answer "was it read?" for the given message object.
Agora, qual estrutura de dados você poderia usar para guardar a informação de que a mensagem "já foi lida"? A estrutura precisa ser bem adequada para responder "ela foi lida?" para um determinado objeto de mensagem.

@gabifs gabifs Nov 7, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"guardar a informação de que a mensagem 'já foi lida'" dá a ideia de registrar um fato já conhecido. O original ("whether the message has been read") fala em guardar se a mensagem foi lida ou não, ou seja, uma resposta sim/não, que é a ideia da solução com WeakSet.

Suggested change
Agora, qual estrutura de dados você poderia usar para guardar a informação de que a mensagem "já foi lida"? A estrutura precisa ser bem adequada para responder "ela foi lida?" para um determinado objeto de mensagem.
Agora, qual estrutura de dados você poderia usar para guardar a informação sobre se a mensagem "já foi lida"? A estrutura precisa ser bem adequada para responder "ela foi lida?" para um determinado objeto de mensagem.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 1-js/05-data-types/08-weakmap-weakset/01-recipients-read/solution.md Outdated

// answer: was the message[0] read?
// resposta: a message[0] foi lida?
alert("Read message 0: " + readMessages.has(messages[0])); // true

@gabifs gabifs Nov 7, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esta string ficou em inglês, mas outras strings dos exemplos foram traduzidas (como "documentos secretos" no artigo):

Suggested change
alert("Read message 0: " + readMessages.has(messages[0])); // true
alert("Mensagem 0 lida: " + readMessages.has(messages[0])); // true

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@diogoosz
Apply review suggestions from gabifs
1b62c50
@diogoosz

diogoosz commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Obrigado pela revisão, @gabifs! Apliquei tudo: troquei "garbage collector" por "coletor de lixo"/"coleta de lixo" (variando pra não repetir) em todas as ocorrências do artigo e do segundo exercício, troquei "map"/"set" genéricos por WeakMap/WeakSet onde fazia sentido (mantive map só onde é literalmente o nome da variável no código), "cachear" → "guardar em cache", corrigi os links do MDN (Weakset → WeakSet), ajustei o enunciado da primeira tarefa e troquei a string em inglês na solução por "Mensagem 0 lida: ".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabifs
gabifs merged commit 3e0e84c into javascript-tutorial:master Nov 7, 2026
1 check passed

Uh oh!

There was an error while loading. Please reload this page.

@gabifs gabifs mentioned this pull request Nov 7, 2026
Portuguese Translation Progress #1
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gabifs gabifs gabifs left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@diogoosz @CLAassistant @gabifs
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.