Skip to content

Conversation

@anapaulalemos
Copy link
Contributor

No description provided.

@wnleao
Copy link
Contributor

wnleao commented May 13, 2020

Hey, Ana! Cheers! I'm reviewing it right now.

@wnleao
Copy link
Contributor

wnleao commented May 13, 2020

Could you double check #120 ? I've made the changes you'd requested. Once you approve it I'll merge it.

# Objeto global

The global object provides variables and functions that are available anywhere. Mostly, the ones that are built into the language or the host environment.
O objeto global fornece variáveis e funções que estão disponíveis em qualquer lugar. Por padrão, aqueles que são incorporados ao idioma ou ao ambiente.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it not be better to use "Em sua maioria" instead of "Por padrão" ?

No navegador ele é chamado de `window`, no Node.js é `global`, em outros ambientes pode ter outro nome.

For instance, we can call `alert` as a method of `window`:
Recentemente, `globalThis` foi adicionado a linguagem como um nome padrão para o objeto global, que deve ser suportado em todos os ambientes. Em alguns navegadores, como o Edge não-Chromium, `globalThis` ainda não é suportado, mas pode ser facilmente utilizado através de um polyfill.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could leave it as "non-Chromium Edge". What do you think?

```html run
<script type="module">
var x = 5;
No navegador, funções e variáveis globais declaradas com `var` (não `let/const`!) tornam-se propriedade do objeto global:
Copy link
Contributor

Choose a reason for hiding this comment

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

minor typo: tornam-se propriedades.

We'll cover more features of modules later, in the chapter [](info:modules).
```js run
*!*
// tornando as informações de current user global, para permitir que todos os script as acessem
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it not be better: "tornando globais as informações..."

name: "John",
age: 30
};
Por exemplo, testar se o objeto interno `Promise` existe (ele não existe em navegadores antigos):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the best translation for built-in would be "nativo" as in https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects

window.Promise = ... // custom implementation of the modern language feature
}
```
Isso inclui objetos internos Javascript, como `Array` e valores específicos do ambiente, como `window.innerHeight` -- a altura da janela no navegador.
Copy link
Contributor

Choose a reason for hiding this comment

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

same as before, internos -> nativos

- O objeto global tem o nome universal `globalThis`.

...And of course, if we're in a browser, using `window` to access browser window features (not as a global object) is completely fine.
...Porém é mais frequentemente referido pelos seu nomes específicos de ambientes "old-school", como `window` (navegador) e `global` (Node.js). Como `globalThis` é uma proposta recente, não é suportado pelo não Chromium Edge (mas pode ser usado com um polyfill).
Copy link
Contributor

Choose a reason for hiding this comment

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

same as before, "non-Chromium Edge"

...And of course, if we're in a browser, using `window` to access browser window features (not as a global object) is completely fine.
...Porém é mais frequentemente referido pelos seu nomes específicos de ambientes "old-school", como `window` (navegador) e `global` (Node.js). Como `globalThis` é uma proposta recente, não é suportado pelo não Chromium Edge (mas pode ser usado com um polyfill).
- Devemos salvar valores no objeto global apenas se eles forem realmente globais em nosso projeto. E manter sua quantidade no mínimo.
- No navegador, ao menos que estejamos usando [modules](info:modules), funções e variáveis globais declaradas com `var` se tornar uma propriedade do objeto global.
Copy link
Contributor

Choose a reason for hiding this comment

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

minor typo: se tornar -> se tornam

...Porém é mais frequentemente referido pelos seu nomes específicos de ambientes "old-school", como `window` (navegador) e `global` (Node.js). Como `globalThis` é uma proposta recente, não é suportado pelo não Chromium Edge (mas pode ser usado com um polyfill).
- Devemos salvar valores no objeto global apenas se eles forem realmente globais em nosso projeto. E manter sua quantidade no mínimo.
- No navegador, ao menos que estejamos usando [modules](info:modules), funções e variáveis globais declaradas com `var` se tornar uma propriedade do objeto global.
- Para tornar nosso código à prova de mudanças no futuro e mais fácil de entender, devemos acessar as propriedades diretamente do objeto global, como `window.x`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to rephrase it: "acessar as propriedades do objeto global diretamente, como...". The way it is, using "diretamente" after "propriedades" kind of changes the meaning of it. What do you think?

@javascript-translate-bot

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@CLAassistant
Copy link

CLAassistant commented May 15, 2020

CLA assistant check
All committers have signed the CLA.

@anapaulalemos
Copy link
Contributor Author

/done

@wnleao wnleao merged commit b49fe5f into javascript-tutorial:master May 16, 2020
@javascript-translate-bot

Thank you 💖 I updated the Progress Issue #1 🎉 🎉 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants