Skip to content

Commit 60ddea1

Browse files
committed
Resolve conflicts.
1 parent b33e869 commit 60ddea1

File tree

9 files changed

+15
-145
lines changed

9 files changed

+15
-145
lines changed

1-js/01-getting-started/1-intro/article.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@ O navegador tem um interpretador(motor) incorporado, às vezes chamado de "máqu
2424

2525
Interpretadores diferentes têm "codinomes" diferentes. Por exemplo:
2626

27-
<<<<<<< HEAD
2827
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- no Chrome e no Opera.
2928
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- no Firefox.
30-
- ...Há outros codinomes como "Chakra" para o IE, "ChakraCore" para Microsoft Edge, "Nitro" e "SquirrelFish" para Safari, etc.
31-
=======
32-
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome and Opera.
33-
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox.
34-
- ...There are other codenames like "Chakra" for IE, "JavaScriptCore", "Nitro" and "SquirrelFish" for Safari, etc.
35-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
29+
- ...Há outros codinomes como "Chakra" para o IE, "JavaScriptCore", "Nitro" e "SquirrelFish" para Safari, etc.
3630

3731
Os termos acima são bons para lembrar, pois são usados em artigos de desenvolvedores na internet. Vamos usá-los também. Por exemplo, se "um recurso X é suportado pelo V8", então ele provavelmente funciona no Chrome e no Opera.
3832

1-js/01-getting-started/4-devtools/article.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ Para que possamos visualizar erros e obter muitas outras informações úteis so
88

99
A maioria dos desenvolvedores escolhem o Chrome ou o Firefox para o desenvolvimento porque esses navegadores têm as melhores ferramentas de desenvolvedor. Outros navegadores também fornecem ferramentas de desenvolvedor, às vezes com recursos especiais, mas geralmente estão jogando "catch-up" no Chrome ou Firefox. Assim, a maioria dos desenvolvedores tem um navegador "favorito" e muda para outros se um problema é específico do navegador.
1010

11-
<<<<<<< HEAD
1211
As ferramentas do desenvolvedor são potentes; elas têm muitos recursos. Para começar, vamos aprender como as abrir, olhar para erros e executar comandos JavaScript.
13-
=======
14-
Developer tools are potent; they have many features. To start, we'll learn how to open them, look at errors, and run JavaScript commands.
15-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
1612

1713
## Google Chrome
1814

1-js/02-first-steps/02-structure/article.md

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ alert(3 +
4646
+ 2);
4747
```
4848

49-
<<<<<<< HEAD
50-
O código produz `6` porque o Javascript não insere pontos e virgulas aqui. É intuitivamente óbvio que se a linha termina com um sinal de mais `"+"`, então é uma "expressão incompleta", logo o ponto e vírgula não é necessário. E neste caso isso funciona como pretendido.
51-
=======
52-
The code outputs `6` because JavaScript does not insert semicolons here. It is intuitively obvious that if the line ends with a plus `"+"`, then it is an "incomplete expression", so a semicolon there would be incorrect. And in this case, that works as intended.
53-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
49+
O código produz `6` porque o Javascript não insere pontos e virgulas aqui. É intuitivamente óbvio que se a linha termina com um sinal de mais `"+"`, então é uma "expressão incompleta", logo o ponto e vírgula aí seria incorreto. E neste caso isso funciona como pretendido.
5450

5551
**Mas há situações em que o JavaScript "falha" em assumir um ponto e vírgula onde ele é realmente necessário.**
5652

@@ -65,63 +61,31 @@ alert("Hello");
6561
[1, 2].forEach(alert);
6662
```
6763
68-
<<<<<<< HEAD
69-
Não há necessidade de pensar sobre o significado dos parênteses `[]` e `forEach` ainda. Nós vamos estudá-los mais tarde. Por enquanto, apenas lembre-se que o resultado do código: mostra `1` e depois` 2`.
64+
Não há necessidade de pensar sobre o significado dos parênteses `[]` e também do `forEach`. Nós vamos estudá-los mais tarde. Por enquanto, apenas lembre-se do resultado da execução do código: ele mostra `Hello`, depois `1`, e depois` 2`.
7065
71-
Agora, vamos adicionar um `alert` antes do código e * não * terminá-lo com um ponto e vírgula:
72-
73-
```js run no-beautify
74-
alert("Haverá um erro")
75-
=======
76-
No need to think about the meaning of the brackets `[]` and `forEach` yet. We'll study them later. For now, just remember the result of running the code: it shows `Hello`, then `1`, then `2`.
77-
78-
Now let's remove the semicolon after the `alert`:
66+
Agora, vamos remover o ponto e vírgula depois do `alert`:
7967
8068
```js run no-beautify
8169
alert("Hello")
82-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
8370
8471
[1, 2].forEach(alert);
8572
```
8673
87-
<<<<<<< HEAD
88-
Agora, se nós executarmos o código, apenas o primeiro `alert` é mostrado e então temos um erro!
89-
90-
Mas tudo está bem novamente se adicionarmos um ponto e vírgula após `alert`:
91-
```js run
92-
alert("Tudo bem agora");
93-
=======
94-
The difference compared to the code above is only one character: the semicolon at the end of the first line is gone.
95-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
96-
97-
If we run this code, only the first `Hello` shows (and there's an error, you may need to open the console to see it). There are no numbers any more.
74+
A diferença em comparação com o código acima é de apenas um caractere: o ponto e vírgula da primeira linha se foi.
9875
99-
<<<<<<< HEAD
100-
Agora temos a mensagem "Tudo bem agora" seguida por "1" e "2".
101-
102-
103-
O erro na variante sem ponto e vírgula ocorre porque o JavaScript não assume um ponto e vírgula antes dos colchetes `[...]`.
104-
105-
Portanto, como o ponto e vírgula não é inserido automaticamente, o código no primeiro exemplo é tratado como uma única instrução. Veja como o mecanismo vê isso:
106-
107-
```js run no-beautify
108-
alert("Haverá um erro")[1, 2].forEach(alert)
109-
```
76+
Se nós executarmos esse código, apenas o primeiro `Hello` é mostrado (e então há um erro, você pode precisar de abrir a consola para o ver). Já não existem mais números.
11077
111-
Mas devem ser duas declarações separadas, não uma. Tal fusão neste caso é completamente errado, daí o erro. Isso pode acontecer em outras situações.
112-
=======
113-
That's because JavaScript does not assume a semicolon before square brackets `[...]`. So, the code in the last example is treated as a single statement.
78+
Isso ocorre porque o JavaScript não assume um ponto e vírgula antes dos colchetes `[...]`. Portanto, o código no último exemplo é tratado como uma única instrução.
11479
115-
Here's how the engine sees it:
80+
Veja como o mecanismo vê isso:
11681
11782
```js run no-beautify
11883
alert("Hello")[1, 2].forEach(alert);
11984
```
12085
121-
Looks weird, right? Such merging in this case is just wrong. We need to put a semicolon after `alert` for the code to work correctly.
86+
Parece estranho, não? Tal fusão neste caso é completamente errada. Nós precisamos de colocar um ponto e vírgula depois de `alert` para o código funcionar corretamente.
12287
123-
This can happen in other situations also.
124-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
88+
Isso também pode acontecer em outras situações.
12589
````
12690

12791
Recomendamos colocar ponto e vírgula entre as frases, mesmo que estejam separadas por novas linhas. Esta regra é amplamente adotada pela comunidade. Vamos notar mais uma vez -- *é possível* deixar de fora os pontos e vírgulas na maior parte do tempo. Mas é mais seguro -- especialmente para um iniciante -- usá-los.

1-js/02-first-steps/15-function-basics/article.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,11 @@ function showMessage() {
2020
}
2121
```
2222

23-
<<<<<<< HEAD
24-
A palavra-chave `function` vem primeiro, depois vem o *nome da função*, e uma lista de *parâmetros* entre os parêntesis (vazio no exemplo acima) e finalmente o código da função, também chamado de "o corpo da função", entre chaves.
25-
26-
```js
27-
function name(parameters) {
28-
...corpo...
29-
=======
30-
The `function` keyword goes first, then goes the *name of the function*, then a list of *parameters* between the parentheses (comma-separated, empty in the example above, we'll see examples later) and finally the code of the function, also named "the function body", between curly braces.
23+
A palavra-chave `function` vem primeiro, depois vem o *nome da função*, e uma lista de *parâmetros* entre os parêntesis (separados por vírgulas, vazia no exemplo acima, veremos exemplos mais tarde) e finalmente o código da função, também chamado de "o corpo da função", entre chaves.
3124

3225
```js
3326
function name(parameter1, parameter2, ... parameterN) {
34-
...body...
35-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
27+
...corpo...
3628
}
3729
```
3830

@@ -202,11 +194,7 @@ For instance, the aforementioned function `showMessage(from, text)` can be calle
202194
showMessage("Ann");
203195
```
204196
205-
<<<<<<< HEAD
206-
That's not an error. Such a call would output `"Ann: undefined"`. There's no `text`, so it's assumed that `text === undefined`.
207-
=======
208197
That's not an error. Such a call would output `"*Ann*: undefined"`. As the value for `text` isn't passed, it becomes `undefined`.
209-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
210198
211199
We can specify the so-called "default" (to use if omitted) value for a parameter in the function declaration, using `=`:
212200

1-js/03-code-quality/01-debugging-chrome/article.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
<<<<<<< HEAD
2-
# Depuração de erros no Chrome
3-
=======
4-
# Debugging in the browser
5-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
1+
# Depuração de erros no navegador
62

73
Antes de escrevermos código mais complexo, vamos falar de debugging (depuração de erros).
84

1-js/03-code-quality/05-testing-mocha/article.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
Teste automatizado será utilizado nos exercícios seguintes, e também é amplamente usado em projetos reais.
44

5-
<<<<<<< HEAD
65
## Porque precisamos de testes?
7-
=======
8-
## Why do we need tests?
9-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
106

117
Quando escrevemos uma função, nós geralmente podemos imaginar o que ela deveria fazer: que parâmetros dariam que resultados.
128

1-js/04-object-basics/09-object-toprimitive/article.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
What happens when objects are added `obj1 + obj2`, subtracted `obj1 - obj2` or printed using `alert(obj)`?
55

6-
<<<<<<< HEAD
7-
There are special methods in objects that do the conversion.
8-
=======
96
JavaScript doesn't exactly allow 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 an addition (or other operators).
107

118
In case of such operations, objects are auto-converted to primitives, and then the operation is carried out over these primitives and results in a primitive value.
@@ -24,7 +21,6 @@ We have two purposes:
2421
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.
2522

2623
## Conversion rules
27-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
2824

2925
In the chapter <info:type-conversions> we've seen the rules for numeric, string and boolean conversions of primitives. But we left a gap for objects. Now, as we know about methods and symbols it becomes possible to close it.
3026

@@ -34,23 +30,11 @@ The numeric conversion happens when we subtract objects or apply mathematical fu
3430

3531
As for the string conversion -- it usually happens when we output an object like `alert(obj)` and in similar contexts.
3632

37-
<<<<<<< HEAD
38-
## ToPrimitive
39-
40-
When an object is used in the context where a primitive is required, for instance, in an `alert` or mathematical operations, it's converted to a primitive value using the `ToPrimitive` algorithm ([specification](https://tc39.github.io/ecma262/#sec-toprimitive)).
41-
42-
That algorithm allows us to customize the conversion using a special object method.
43-
44-
Depending on the context, the conversion has a so-called "hint".
45-
46-
There are three variants:
47-
=======
4833
We can fine-tune string and numeric conversion, using special object methods.
4934

5035
There are three variants of type conversion, that happen in various situations.
5136

5237
They're called "hints", as described in the [specification](https://tc39.github.io/ecma262/#sec-toprimitive):
53-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
5438

5539
`"string"`
5640
: When an operation expects a string, for object-to-string conversions, like `alert`:
@@ -117,12 +101,8 @@ Let's start from the first method. There's a built-in symbol named `Symbol.toPri
117101
118102
```js
119103
obj[Symbol.toPrimitive] = function(hint) {
120-
<<<<<<< HEAD
121-
// return a primitive value
122-
=======
123104
// here goes the code to convert this object to a primitive
124105
// it must return a primitive value
125-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
126106
// hint = one of "string", "number", "default"
127107
}
128108
```
@@ -223,12 +203,7 @@ alert(user + 500); // toString -> John500
223203

224204
In the absence of `Symbol.toPrimitive` and `valueOf`, `toString` will handle all primitive conversions.
225205

226-
<<<<<<< HEAD
227-
228-
## ToPrimitive and ToString/ToNumber
229-
=======
230206
### A conversion can return any primitive type
231-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
232207

233208
The important thing to know about all primitive-conversion methods is that they do not necessarily return the "hinted" primitive.
234209

1-js/05-data-types/01-primitives-methods/article.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@ Objetos são "mais pesados" que primitivos. Eles exigem recursos adicionais para
4141

4242
Aqui está o paradoxo enfrentado pelo criador do JavaScript:
4343

44-
<<<<<<< HEAD
45-
- Há muitas coisas que alguém poderia querer fazer com um primitivo como uma string ou um número. Seria ótimo acessá-los como métodos.
46-
- Primitivos devem ser o mais rápido e leve possível.
47-
=======
48-
- There are many things one would want to do with a primitive like a string or a number. It would be great to access them using methods.
49-
- Primitives must be as fast and lightweight as possible.
50-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
44+
- Há muitas coisas que alguém poderia querer fazer com um primitivo como uma string ou um número. Seria ótimo acessá-los usando métodos.
45+
- Primitivos devem ser o mais rápidos e leves possível.
5146

5247
A solução parece um pouco estranha, mas aqui está:
5348

1-js/13-modules/01-modules-intro/article.md

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ There are core features, valid both for browser and server-side JavaScript.
6969

7070
### Always "use strict"
7171

72-
<<<<<<< HEAD
73-
Modules always `use strict`. E.g. assigning to an undeclared variable will give an error.
74-
=======
7572
Modules always work in strict mode. E.g. assigning to an undeclared variable will give an error.
76-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
7773

7874
```html run
7975
<script type="module">
@@ -93,26 +89,18 @@ In the example below, two scripts are imported, and `hello.js` tries to use `use
9389

9490
Modules should `export` what they want to be accessible from outside and `import` what they need.
9591

96-
<<<<<<< HEAD
97-
So we should import `user.js` directly into `hello.js` instead of `index.html`.
98-
=======
9992
- `user.js` should export the `user` variable.
10093
- `hello.js` should import it from `user.js` module.
10194

10295
In other words, with modules we use import/export instead of relying on global variables.
103-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
10496

10597
This is the correct variant:
10698

10799
[codetabs src="scopes-working" height="140" current="hello.js"]
108100

109-
<<<<<<< HEAD
110-
In the browser, independant top-level scope also exists for each `<script type="module">`:
111-
=======
112101
In the browser, if we talk about HTML pages, independent top-level scope also exists for each `<script type="module">`.
113102

114103
Here are two scripts on the same page, both `type="module"`. They don't see each other's top-level variables:
115-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
116104

117105
```html run
118106
<script type="module">
@@ -127,17 +115,13 @@ Here are two scripts on the same page, both `type="module"`. They don't see each
127115
</script>
128116
```
129117

130-
<<<<<<< HEAD
131-
If we really need to make a "global" in-browser variable, we can explicitly assign it to `window` and access as `window.user`. But that's an exception requiring a good reason.
132-
=======
133118
```smart
134119
In the browser, we can make a variable window-level global by explicitly assigning it to a `window` property, e.g. `window.user = "John"`.
135120
136121
Then all scripts will see it, both with `type="module"` and without it.
137122
138123
That said, making such global variables is frowned upon. Please try to avoid them.
139124
```
140-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
141125

142126
### A module code is evaluated only the first time when imported
143127

@@ -164,11 +148,7 @@ import `./alert.js`; // Module is evaluated!
164148
import `./alert.js`; // (nothing)
165149
```
166150

167-
<<<<<<< HEAD
168-
In practice, top-level module code is mostly used for initialization. We create data structures, pre-fill them, and if we want something to be reusable -- export it.
169-
=======
170151
The second import shows nothing, because the module has already been evaluated.
171-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
172152

173153
There's a rule: top-level module code should be used for initialization, creation of module-specific internal data structures. If we need to make something callable multiple times - we should export it as a function, like we did with `sayHi` above.
174154

@@ -202,13 +182,9 @@ alert(admin.name); // Pete
202182
*/!*
203183
```
204184

205-
<<<<<<< HEAD
206-
So, let's reiterate -- the module is executed only once. Exports are generated, and then they are shared between importers, so if something changes the `admin` object, other modules will see that .
207-
=======
208185
As you can see, when `1.js` changes the `name` property in the imported `admin`, then `2.js` can see the new `admin.name`.
209186

210187
That's exactly because the module is executed only once. Exports are generated, and then they are shared between importers, so if something changes the `admin` object, other modules will see that.
211-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
212188

213189
**Such behavior is actually very convenient, because it allows us to *configure* modules.**
214190

@@ -230,29 +206,19 @@ export function sayHi() {
230206
}
231207
```
232208

233-
<<<<<<< HEAD
234-
Now, in `init.js`, the first script of our app, we set `admin.name`. Then everyone will see it, including calls made from inside `admin.js` itself:
235-
=======
236209
Here, `admin.js` exports the `config` object (initially empty, but may have default properties too).
237210

238211
Then in `init.js`, the first script of our app, we import `config` from it and set `config.user`:
239-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
240212

241213
```js
242214
// 📁 init.js
243215
import {config} from './admin.js';
244216
config.user = "Pete";
245217
```
246218

247-
<<<<<<< HEAD
248-
```js
249-
// 📁 other.js
250-
import {admin, sayHi} from './admin.js';
251-
=======
252219
...Now the module `admin.js` is configured.
253220

254221
Further importers can call it, and it correctly shows the current user:
255-
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
256222

257223
```js
258224
// 📁 another.js

0 commit comments

Comments
 (0)