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 — Object to primitive conversion by diogoosz · Pull Request #489 · javascript-tutorial/pt.javascript.info

Conversation

@diogoosz

@diogoosz diogoosz commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Tradução do artigo "Object to primitive conversion" para o português.

Conforme comentado na #1. Obs.: esse título já havia sido reivindicado por @DesKd em fev/2026, sem PR desde então — estou assumindo a tradução.

Sorry, something went wrong.

Uh oh!

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

All reactions
@diogoosz @claude
Translate "Object to primitive conversion" article to Portuguese
dd64893
Co-Authored-By: Claude Sonnet 5 <[email protected]>
gabifs
gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
A coisa importante de se saber sobre todos os métodos de conversão de primitivo é que eles não necessariamente retornam o primitivo "sugerido pelo hint".

There is no control whether `toString` returns exactly a string, or whether `Symbol.toPrimitive` method returns a number for the hint `"number"`.
Não há nenhum controle sobre se `toString` retorna exatamente uma string, ou se o método `Symbol.toPrimitive` retorna um número para o hint `"number"`.

@gabifs gabifs Nov 12, 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.

Tradução ambígua: "There is no control whether" significa que não há verificação/garantia de que o retorno seja do tipo sugerido. "Não há nenhum controle sobre se..." é truncado e pode ser lido como "não podemos controlar". Sugestão: "Não há nenhuma verificação de que toString retorne exatamente uma string, ou de que o método Symbol.toPrimitive retorne um número para o hint \"number\"."

Sorry, something went wrong.

Uh oh!

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

All reactions
gabifs
gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
- try calling `obj.toString()` or `obj.valueOf()`, whatever exists.
3. Otherwise if hint is `"number"` or `"default"`
- try calling `obj.valueOf()` or `obj.toString()`, whatever exists.
1. Chama `obj[Symbol.toPrimitive](hint)` -- o método com a chave simbólica `Symbol.toPrimitive` (symbol do sistema), se esse método existir,

@gabifs gabifs Nov 12, 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.

O original usa um hífen simples (-) e esta linha passou a usar --. Mudança de pontuação fora do escopo da tradução; sugiro manter - como no original (ou usar o mesmo travessão da linha 29, mas de forma deliberada).

Sorry, something went wrong.

Uh oh!

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

All reactions
gabifs
gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
: Ocorre em casos raros, quando o operador "não tem certeza" de qual tipo esperar.

For instance, binary plus `+` can work both with strings (concatenates them) and numbers (adds them). So if a binary plus gets an object as an argument, it uses the `"default"` hint to convert it.
Por exemplo, o mais binário `+` pode funcionar tanto com strings (concatenando elas) quanto com números (somando eles). Então, se um mais binário recebe um objeto como argumento, ele usa o hint `"default"` pra convertê-lo.

@gabifs gabifs Nov 12, 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.

Registro coloquial: "concatenando elas" / "somando eles" usa pronome reto como objeto. No texto didático, prefira "concatenando-as" / "somando-os". Também pra aqui destoa do para usado no resto do artigo.

Sorry, something went wrong.

Uh oh!

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

All reactions
gabifs
gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
O que acontece quando objetos são somados `obj1 + obj2`, subtraídos `obj1 - obj2` ou exibidos usando `alert(obj)`?

JavaScript doesn't allow you to customize how operators work on objects. Unlike some other programming languages, such as Ruby or C++, we can't implement a special object method to handle addition (or other operators).
O JavaScript não permite que você personalize como os operadores funcionam em objetos. Diferente de outras linguagens de programação, como Ruby ou C++, não podemos implementar um método especial de objeto pra lidar com a adição (ou outros operadores).

@gabifs gabifs Nov 12, 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.

Inconsistência de registro: o artigo mistura pra (linhas 6, 14, 72, 92) com para (maioria das ocorrências). Sugiro padronizar em para, como nos demais artigos traduzidos.

Sorry, something went wrong.

Uh oh!

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

All reactions
gabifs
gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
// hint = one of "string", "number", "default"
// aqui vai o código para converter este objeto para um primitivo
// ele precisa retornar um valor primitivo
// hint = um de "string", "number", "default"

@gabifs gabifs Nov 12, 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.

Calque do inglês "one of": "um de" soa estranho em português. Sugestão: // hint = um entre "string", "number", "default".

Sorry, something went wrong.

Uh oh!

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

All reactions
gabifs
gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
```

So if we try to use an object as a string, like in an `alert` or so, then by default we see `[object Object]`.
Então, se tentarmos usar um objeto como uma string, tipo num `alert` ou algo assim, então por padrão vemos `[object Object]`.

@gabifs gabifs Nov 12, 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.

Registro informal ("tipo num alert ou algo assim") destoa do resto do texto. Sugestão: "como num alert ou similar".

Sorry, something went wrong.

Uh oh!

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

All reactions
gabifs
gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
1. It will allow us to understand what's going on in case of coding mistakes, when such an operation happened accidentally.
2. There are exceptions, where such operations are possible and look good. E.g. subtracting or comparing dates (`Date` objects). We'll come across them later.
1. Vai nos permitir entender o que está acontecendo em caso de erros de código, quando esse tipo de operação acontece acidentalmente.
2. Existem exceções, onde esse tipo de operação é possível e fica legal. Ex.: subtrair ou comparar datas (objetos `Date`). Vamos nos deparar com elas mais tarde.

@gabifs gabifs Nov 12, 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.

"fica legal" é coloquial demais para "look good". Sugestão: "e fazem sentido" / "e ficam elegantes".

Sorry, something went wrong.

Uh oh!

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

All reactions
gabifs
gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
Essa é uma limitação importante: o resultado de `obj1 + obj2` (ou outra operação matemática) não pode ser outro objeto!

E.g. we can't make objects representing vectors or matrices (or achievements or whatever), add them and expect a "summed" object as the result. Such architectural feats are automatically "off the board".
Ex.: não podemos fazer objetos representando vetores ou matrizes (ou conquistas ou qualquer outra coisa), somá-los e esperar um objeto "somado" como resultado. Esses feitos arquiteturais são automaticamente "tirados de cena".

@gabifs gabifs Nov 12, 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.

"tirados de cena" não transmite bem "off the board" (= fora de cogitação, impossível). Sugestão: "Esses feitos arquiteturais estão automaticamente "fora de cogitação"."

Sorry, something went wrong.

Uh oh!

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

All reactions
@gabifs gabifs mentioned this pull request Nov 12, 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.

2 participants

@diogoosz @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.