-
Notifications
You must be signed in to change notification settings - Fork 114
Global object #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global object #123
Conversation
Hey, Ana! Cheers! I'm reviewing it right now. |
Could you double check #120 ? I've made the changes you'd requested. Once you approve it I'll merge it. |
|
||
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. |
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.
Would it not be better to use "Em sua maioria" instead of "Por padrão" ?
|
||
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. |
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.
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: |
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.
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 |
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.
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): |
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.
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. |
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.
same as before, internos -> nativos
|
||
...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). |
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.
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. |
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.
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`. |
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.
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?
Please make the requested changes. After it, add a comment "/done". |
/done |
Thank you 💖 I updated the Progress Issue #1 🎉 🎉 🎉 |
No description provided.