Skip to content

Commit 0a979e3

Browse files
Merge pull request #2 from daliannyvieira/master
Hello, I just translated a chapter about mode strict
2 parents 3ed52e1 + b7a71a4 commit 0a979e3

File tree

2 files changed

+27
-38
lines changed

2 files changed

+27
-38
lines changed

1-js/02-first-steps/01-hello-world/article.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ O exemplo acima pode ser dividido em dois scripts para funcionar:
123123
alert(1);
124124
</script>
125125
```
126-
````
127126

128127
## Resumo
129128

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,69 @@
1-
# The modern mode, "use strict"
1+
# O modo moderno, "use strict"
22

3-
For a long time, JavaScript evolved without compatibility issues. New features were added to the language while old functionality didn't change.
3+
Por um longo tempo, o JavaScript evoluiu sem problemas de compatibilidade. Novos recursos foram adicionados ao idioma enquanto as funcionalidades antigas não foram alteradas.
44

5-
That had the benefit of never breaking existing code. But the downside was that any mistake or an imperfect decision made by JavaScript's creators got stuck in the language forever.
5+
Isso teve o benefício de nunca quebrar o código existente. Mas a desvantagem foi que qualquer erro ou decisão imperfeita feita pelos criadores do JavaScript acabou ficando presa na linguagem para sempre.
66

7-
This was the case until 2009 when ECMAScript 5 (ES5) appeared. It added new features to the language and modified some of the existing ones. To keep the old code working, most modifications are off by default. You need to explicitly enable them with a special directive: `"use strict"`.
7+
Este foi o caso até 2009, quando ECMAScript 5 (ES5) apareceu. Adicionou novos recursos à linguagem e modificou alguns dos existentes. Para manter o código antigo funcionando, a maioria das modificações está desativada por padrão. Você precisa habilitá-los explicitamente com uma diretiva especial: `" use strict "`.
88

99
## "use strict"
1010

11-
The directive looks like a string: `"use strict"` or `'use strict'`. When it is located at the top of a script, the whole script works the "modern" way.
11+
A diretiva parece uma string `"use strict"` ou `'use strict'`. Quando ele está localizado no topo de um script, todo o script funciona da maneira "moderna".
1212

1313
For example:
1414

1515
```js
1616
"use strict";
1717

18-
// this code works the modern way
18+
// esse código funciona de forma moderna
1919
...
2020
```
2121

22-
We will learn functions (a way to group commands) soon.
22+
Nós vamos aprender sobre funções, uma forma de agupar comandos, em breve.
2323

24-
Looking ahead, let's just note that `"use strict"` can be put at the start of most kinds of functions instead of the whole script. Doing that enables strict mode in that function only. But usually, people use it for the whole script.
2524

25+
Vamos apenas observar que "use strict" pode ser colocado no início da maioria dos tipos de funções em vez do script inteiro. Fazer isso habilita o modo estrito apenas nessa função. Mas geralmente, as pessoas usam no script inteiro.
2626

27-
````warn header="Ensure that \"use strict\" is at the top"
28-
Please make sure that `"use strict"` is at the top of your scripts, otherwise strict mode may not be enabled.
29-
30-
Strict mode isn't enabled here:
27+
O modo estrito não está ativado aqui:
3128

3229
```js no-strict
33-
alert("some code");
34-
// "use strict" below is ignored--it must be at the top
30+
alert("algum código");
31+
// "use strict" abaixo é ignorado - deve estar no topo
3532

3633
"use strict";
3734

38-
// strict mode is not activated
35+
// modo estrito não está ativado
3936
```
4037

41-
Only comments may appear above `"use strict"`.
42-
````
43-
44-
```warn header="There's no way to cancel `use strict`"
45-
There is no directive like `"no use strict"` that reverts the engine to old behavior.
46-
47-
Once we enter strict mode, there's no return.
48-
```
38+
Apenas comentários devem aparecer acima de `"use strict"`.
4939

50-
## Browser console
40+
## Console do navegador
5141

52-
For the future, when you use a browser console to test features, please note that it doesn't `use strict` by default.
42+
Para o futuro, quando você usar o console do navegador para testar funcionalidades, observe que ele não "usa strict" por padrão.
5343

54-
Sometimes, when `use strict` makes a difference, you'll get incorrect results.
44+
As vezes, quando usar `use strict` faz alguma diferença, você terá resultados incorretos.
5545

56-
Even if we press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, it doesn't work. That's because of how the console executes the code internally.
46+
Mesmo se pressionarmos `key: Shift + Enter` para inserir várias linhas e colocar` use strict` no topo, isso não funcionará. Isso é por causa de como o console executa o código internamente.
5747

58-
The reliable way to ensure `use strict` would be to input the code into console like this:
48+
A maneira confiável de garantir `use strict` seria inserir o código no console da seguinte forma:
5949

6050
```js
6151
(function() {
6252
'use strict';
6353

64-
// ...your code...
54+
// ...seu código...
6555
})()
6656
```
6757

68-
## Always "use strict"
58+
## Sempre "use strict"
6959

70-
We have yet to cover the differences between strict mode and the "default" mode.
60+
Ainda precisamos cobrir as diferenças entre o modo estrito e o modo "padrão".
7161

72-
In the next chapters, as we learn language features, we'll note the differences between the strict and default modes. Luckily, there aren't many and they actually make our lives better.
62+
Nos próximos capítulos, assim como nós vamos aprender novas funcinalidades, vamos aprender as diferenças entre o modo estrito e os modos padrões. Felizmente, não há muitos e eles realmente tornam nossas vidas melhores.
7363

74-
For now, it's enough to know about it in general:
64+
Por agora, de um momento geral, basta saber sobre isso:
7565

76-
1. The `"use strict"` directive switches the engine to the "modern" mode, changing the behavior of some built-in features. We'll see the details later in the tutorial.
77-
2. Strict mode is enabled by placing `"use strict"` at the top of a script or function. Several language features, like "classes" and "modules", enable strict mode automatically.
78-
3. Strict mode is supported by all modern browsers.
79-
4. We recommended always starting scripts with `"use strict"`. All examples in this tutorial assume strict mode unless (very rarely) specified otherwise.
66+
1. A diretiva `" use strict "` alterna o mecanismo para o modo "moderno", alterando o comportamento de alguns recursos internos. Vamos ver os detalhes mais tarde no tutorial.
67+
2. O modo estrito é ativado colocando `" use strict "` no topo de um script ou função. Vários recursos de idioma, como "classes" e "módulos", ativam o modo estrito automaticamente.
68+
3. Modo estrito é suportado por todos os navegadores modernos.
69+
4. Recomendamos sempre iniciar scripts com `" use strict "`. Todos os exemplos neste tutorial assumem o modo estrito, a menos que (muito raramente) seja especificado de outra forma.

0 commit comments

Comments
 (0)