Skip to content

Commit b33e869

Browse files
committed
merging all conflicts
2 parents 453a42f + fb4fc33 commit b33e869

File tree

48 files changed

+318
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+318
-131
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ 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
2728
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- no Chrome e no Opera.
2829
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- no Firefox.
2930
- ...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
3036
3137
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.
3238

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ 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
1112
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
1216
1317
## Google Chrome
1418

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

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

49+
<<<<<<< HEAD
4950
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
5054
5155
**Mas há situações em que o JavaScript "falha" em assumir um ponto e vírgula onde ele é realmente necessário.**
5256

@@ -56,28 +60,43 @@ Erros que ocorrem em tais casos são bastante difíceis de encontrar e corrigir.
5660
Se você está curioso para ver um exemplo concreto de tal erro, verifique este código:
5761
5862
```js run
59-
[1, 2].forEach(alert)
63+
alert("Hello");
64+
65+
[1, 2].forEach(alert);
6066
```
6167
68+
<<<<<<< HEAD
6269
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`.
6370
6471
Agora, vamos adicionar um `alert` antes do código e * não * terminá-lo com um ponto e vírgula:
6572
6673
```js run no-beautify
6774
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`:
79+
80+
```js run no-beautify
81+
alert("Hello")
82+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
6883
69-
[1, 2].forEach(alert)
84+
[1, 2].forEach(alert);
7085
```
7186
87+
<<<<<<< HEAD
7288
Agora, se nós executarmos o código, apenas o primeiro `alert` é mostrado e então temos um erro!
7389
7490
Mas tudo está bem novamente se adicionarmos um ponto e vírgula após `alert`:
7591
```js run
7692
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
7796
78-
[1, 2].forEach(alert)
79-
```
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.
8098
99+
<<<<<<< HEAD
81100
Agora temos a mensagem "Tudo bem agora" seguida por "1" e "2".
82101
83102
@@ -90,6 +109,19 @@ alert("Haverá um erro")[1, 2].forEach(alert)
90109
```
91110
92111
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.
114+
115+
Here's how the engine sees it:
116+
117+
```js run no-beautify
118+
alert("Hello")[1, 2].forEach(alert);
119+
```
120+
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.
122+
123+
This can happen in other situations also.
124+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
93125
````
94126

95127
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/05-types/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Os valores numéricos especiais pertencem formalmente ao tipo "número". Claro q
6464

6565
Veremos mais sobre como trabalhar com números no capítulo <info:number>.
6666

67-
## BigInt
67+
## BigInt [#bigint-type]
6868

6969
In JavaScript, the "number" type cannot represent integer values larger than <code>(2<sup>53</sup>-1)</code> (that's `9007199254740991`), or less than <code>-(2<sup>53</sup>-1)</code> for negatives. It's a technical limitation caused by their internal representation.
7070

1-js/02-first-steps/08-operators/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ In school maths, we write that as a<sup>b</sup>.
6363
For instance:
6464

6565
```js run
66-
alert( 2 ** 2 ); // 2² = 4
67-
alert( 2 ** 3 ); // 2³ = 8
66+
alert( 2 ** 2 ); // 2² = 4
67+
alert( 2 ** 3 ); // 2³ = 8
6868
alert( 2 ** 4 ); // 2⁴ = 16
6969
```
7070

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

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

23+
<<<<<<< HEAD
2324
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.
2425

2526
```js
2627
function name(parameters) {
2728
...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.
31+
32+
```js
33+
function name(parameter1, parameter2, ... parameterN) {
34+
...body...
35+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
2836
}
2937
```
3038
@@ -137,26 +145,23 @@ It's a good practice to minimize the use of global variables. Modern code has fe
137145
138146
## Parameters
139147
140-
We can pass arbitrary data to functions using parameters (also called *function arguments*) .
148+
We can pass arbitrary data to functions using parameters.
141149
142150
In the example below, the function has two parameters: `from` and `text`.
143151
144152
```js run
145-
function showMessage(*!*from, text*/!*) { // arguments: from, text
153+
function showMessage(*!*from, text*/!*) { // parameters: from, text
146154
alert(from + ': ' + text);
147155
}
148156
149-
*!*
150-
showMessage('Ann', 'Hello!'); // Ann: Hello! (*)
151-
showMessage('Ann', "What's up?"); // Ann: What's up? (**)
152-
*/!*
157+
*!*showMessage('Ann', 'Hello!');*/!* // Ann: Hello! (*)
158+
*!*showMessage('Ann', "What's up?");*/!* // Ann: What's up? (**)
153159
```
154160
155161
When the function is called in lines `(*)` and `(**)`, the given values are copied to local variables `from` and `text`. Then the function uses them.
156162
157163
Here's one more example: we have a variable `from` and pass it to the function. Please note: the function changes `from`, but the change is not seen outside, because a function always gets a copy of the value:
158164
159-
160165
```js run
161166
function showMessage(from, text) {
162167

@@ -175,19 +180,35 @@ showMessage(from, "Hello"); // *Ann*: Hello
175180
alert( from ); // Ann
176181
```
177182
183+
When a value is passed as a function parameter, it's also called an *argument*.
184+
185+
In other words, to put these terms straight:
186+
187+
- A parameter is the variable listed inside the parentheses in the function declaration (it's a declaration time term)
188+
- An argument is the value that is passed to the function when it is called (it's a call time term).
189+
190+
We declare functions listing their parameters, then call them passing arguments.
191+
192+
In the example above, one might say: "the function `sayMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".
193+
194+
178195
## Default values
179196
180-
If a parameter is not provided, then its value becomes `undefined`.
197+
If a function is called, but an argument is not provided, then the corresponding value becomes `undefined`.
181198
182199
For instance, the aforementioned function `showMessage(from, text)` can be called with a single argument:
183200
184201
```js
185202
showMessage("Ann");
186203
```
187204
205+
<<<<<<< HEAD
188206
That's not an error. Such a call would output `"Ann: undefined"`. There's no `text`, so it's assumed that `text === undefined`.
207+
=======
208+
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
189210
190-
If we want to use a "default" `text` in this case, then we can specify it after `=`:
211+
We can specify the so-called "default" (to use if omitted) value for a parameter in the function declaration, using `=`:
191212
192213
```js run
193214
function showMessage(from, *!*text = "no text given"*/!*) {
@@ -211,19 +232,23 @@ function showMessage(from, text = anotherFunction()) {
211232
```smart header="Evaluation of default parameters"
212233
In JavaScript, a default parameter is evaluated every time the function is called without the respective parameter.
213234

214-
In the example above, `anotherFunction()` is called every time `showMessage()` is called without the `text` parameter.
235+
In the example above, `anotherFunction()` isn't called at all, if the `text` parameter is provided.
236+
237+
On the other hand, it's independently called every time when `text` is missing.
215238
```
216239

217240
### Alternative default parameters
218241

219-
Sometimes it makes sense to set default values for parameters not in the function declaration, but at a later stage, during its execution.
242+
Sometimes it makes sense to assign default values for parameters not in the function declaration, but at a later stage.
220243

221-
To check for an omitted parameter, we can compare it with `undefined`:
244+
We can check if the parameter is passed during the function execution, by comparing it with `undefined`:
222245

223246
```js run
224247
function showMessage(text) {
248+
// ...
249+
225250
*!*
226-
if (text === undefined) {
251+
if (text === undefined) { // if the parameter is missing
227252
text = 'empty message';
228253
}
229254
*/!*
@@ -234,21 +259,21 @@ function showMessage(text) {
234259
showMessage(); // empty message
235260
```
236261
237-
...Or we could use the `||` operator:
262+
...Or we could use the `??` operator:
238263
239264
```js
240-
// if text parameter is omitted or "" is passed, set it to 'empty'
241265
function showMessage(text) {
266+
// if text is undefined or otherwise falsy, set it to 'empty'
242267
text = text || 'empty';
243268
...
244269
}
245270
```
246271
247-
Modern JavaScript engines support the [nullish coalescing operator](info:nullish-coalescing-operator) `??`, it's better when falsy values, such as `0`, are considered regular:
272+
Modern JavaScript engines support the [nullish coalescing operator](info:nullish-coalescing-operator) `??`, it's better when most falsy values, such as `0`, should be considered "normal":
248273
249274
```js run
250-
// if there's no "count" parameter, show "unknown"
251275
function showCount(count) {
276+
// if count is undefined or null, show "unknown"
252277
alert(count ?? "unknown");
253278
}
254279

@@ -411,7 +436,7 @@ Functions that are used *very often* sometimes have ultrashort names.
411436

412437
For example, the [jQuery](http://jquery.com) framework defines a function with `$`. The [Lodash](http://lodash.com/) library has its core function named `_`.
413438

414-
These are exceptions. Generally functions names should be concise and descriptive.
439+
These are exceptions. Generally function names should be concise and descriptive.
415440
```
416441

417442
## Functions == Comments

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
<<<<<<< HEAD
12
# Depuração de erros no Chrome
3+
=======
4+
# Debugging in the browser
5+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
26
37
Antes de escrevermos código mais complexo, vamos falar de debugging (depuração de erros).
48

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

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

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

5+
<<<<<<< HEAD
56
## Porque precisamos de testes?
7+
=======
8+
## Why do we need tests?
9+
>>>>>>> fb4fc33a2234445808100ddc9f5e4dcec8b3d24c
610
711
Quando escrevemos uma função, nós geralmente podemos imaginar o que ela deveria fazer: que parâmetros dariam que resultados.
812

1-js/03-code-quality/06-polyfills/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Modern project build systems, such as [webpack](http://webpack.github.io/), prov
4848
4949
New language features may include not only syntax constructs and operators, but also built-in functions.
5050
51-
For example, `Math.trunc(n)` is a function that "cuts off" the decimal part of a number, e.g `Math.trunc(1.23) = 1`.
51+
For example, `Math.trunc(n)` is a function that "cuts off" the decimal part of a number, e.g `Math.trunc(1.23)` returns `1`.
5252
5353
In some (very outdated) JavaScript engines, there's no `Math.trunc`, so such code will fail.
5454

1-js/04-object-basics/04-object-methods/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ user = {
8181
// method shorthand looks better, right?
8282
user = {
8383
*!*
84-
sayHi() { // same as "sayHi: function()"
84+
sayHi() { // same as "sayHi: function(){...}"
8585
*/!*
8686
alert("Hello");
8787
}

0 commit comments

Comments
 (0)