Skip to content

Commit f2ec0d3

Browse files
committed
merging all conflicts
2 parents 58b686a + bae0ef4 commit f2ec0d3

File tree

16 files changed

+52
-17
lines changed

16 files changed

+52
-17
lines changed

1-js/02-first-steps/05-types/article.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,23 @@ Além dos números regulares, existem os chamados "valores numéricos especiais"
4646
alert( "not a number" / 2 ); // NaN, tal divisão é errônea
4747
```
4848

49+
<<<<<<< HEAD
4950
`NaN` é pegajoso. Qualquer outra operação em `NaN` retorna `NaN`:
51+
=======
52+
`NaN` is sticky. Any further mathematical operation on `NaN` returns `NaN`:
53+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
5054

5155
```js run
52-
alert( "not a number" / 2 + 5 ); // NaN
56+
alert( NaN + 1 ); // NaN
57+
alert( 3 * NaN ); // NaN
58+
alert( "not a number" / 2 - 1 ); // NaN
5359
```
5460

61+
<<<<<<< HEAD
5562
Então, se há um `NaN` em algum lugar em uma expressão matemática, ele se propaga para o resultado inteiro.
63+
=======
64+
So, if there's a `NaN` somewhere in a mathematical expression, it propagates to the whole result (there's only one exception to that: `NaN ** 0` is `1`).
65+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
5666

5767
```smart header="As operações matemáticas são seguras"
5868
Fazer matemática é "seguro" em JavaScript. Podemos fazer qualquer coisa: dividir por zero, tratar strings não-numéricas como números, etc.

1-js/02-first-steps/12-nullish-coalescing-operator/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ In practice, the zero height is often a valid value, that shouldn't be replaced
106106
107107
## Precedence
108108
109-
The precedence of the `??` operator is about the same as `||`, just a bit lower. It equals `5` in the [MDN table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table), while `||` is `6`.
109+
The precedence of the `??` operator is the same as `||`. They both equal `4` in the [MDN table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table).
110110
111111
That means that, just like `||`, the nullish coalescing operator `??` is evaluated before `=` and `?`, but after most other operations, such as `+`, `*`.
112112

1-js/02-first-steps/16-function-expressions/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function sayHi() {
1212

1313
There is another syntax for creating a function that is called a *Function Expression*.
1414

15-
It allows to create a new function in the middle of any expression.
15+
It allows us to create a new function in the middle of any expression.
1616

1717
For example:
1818

1-js/02-first-steps/17-arrow-functions-basics/article.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ let sum = function(a, b) {
3333
alert( sum(1, 2) ); // 3
3434
```
3535

36+
<<<<<<< HEAD
3637
Como pode ver, `(a, b) => a + b` significa uma função que aceita dois argumentos, nomeadamente `a` e `b`. No momento da execução, esta avalia a expressão `a + b` e retorna o resultado.
38+
=======
39+
As you can see, `(a, b) => a + b` means a function that accepts two arguments named `a` and `b`. Upon the execution, it evaluates the expression `a + b` and returns the result.
40+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
3741
3842
- Se tivermos apenas um argumento, então os parênteses à sua volta podem ser omitidos, tornando ela ainda mais curta.
3943

@@ -86,7 +90,11 @@ Desta forma:
8690
let sum = (a, b) => { // a chaveta abre uma função multi-linha
8791
let result = a + b;
8892
*!*
93+
<<<<<<< HEAD
8994
return result; // se usarmos chavetas, então precisamos de um "return" explícito
95+
=======
96+
return result; // if we use curly braces, then we need an explicit "return"
97+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
9098
*/!*
9199
};
92100

1-js/04-object-basics/04-object-methods/8-chain-calls/_js.view/solution.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ let ladder = {
1111
},
1212
showStep: function() {
1313
alert(this.step);
14+
return this;
1415
}
1516
};

1-js/04-object-basics/04-object-methods/8-chain-calls/_js.view/test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ describe('Ladder', function() {
3232
it('down().up().up().up() ', function() {
3333
assert.equal(ladder.down().up().up().up().step, 2);
3434
});
35+
36+
it('showStep() should return this', function() {
37+
assert.equal(ladder.showStep(), ladder);
38+
});
39+
40+
it('up().up().down().showStep().down().showStep()', function () {
41+
assert.equal(ladder.up().up().down().showStep().down().showStep().step, 0)
42+
});
3543

3644
after(function() {
3745
ladder.step = 0;

1-js/04-object-basics/07-optional-chaining/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ That's the expected result. JavaScript works like this. As `user.address` is `un
2525

2626
In many practical cases we'd prefer to get `undefined` instead of an error here (meaning "no street").
2727

28-
...And another example. In the web development, we can get an object that corresponds to a web page element using a special method call, such as `document.querySelector('.elem')`, and it returns `null` when there's no such element.
28+
...and another example. In Web development, we can get an object that corresponds to a web page element using a special method call, such as `document.querySelector('.elem')`, and it returns `null` when there's no such element.
2929

3030
```js run
3131
// document.querySelector('.elem') is null if there's no element

1-js/05-data-types/10-destructuring-assignment/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The two most used data structures in JavaScript are `Object` and `Array`.
55
- Objects allow us to create a single entity that stores data items by key.
66
- Arrays allow us to gather data items into an ordered list.
77

8-
Although, when we pass those to a function, it may need not an object/array as a whole. It may need individual pieces.
8+
Although, when we pass those to a function, it may need not be an object/array as a whole. It may need individual pieces.
99

1010
*Destructuring assignment* is a special syntax that allows us to "unpack" arrays or objects into a bunch of variables, as sometimes that's more convenient.
1111

1-js/11-async/01-callbacks/article.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ So the single `callback` function is used both for reporting errors and passing
195195

196196
## Pyramid of Doom
197197

198-
From the first look, it's a viable way of asynchronous coding. And indeed it is. For one or maybe two nested calls it looks fine.
198+
At first glance, it looks like a viable approach to asynchronous coding. And indeed it is. For one or maybe two nested calls it looks fine.
199199

200-
But for multiple asynchronous actions that follow one after another we'll have code like this:
200+
But for multiple asynchronous actions that follow one after another, we'll have code like this:
201201

202202
```js
203203
loadScript('1.js', function(error, script) {
@@ -228,8 +228,8 @@ loadScript('1.js', function(error, script) {
228228
```
229229

230230
In the code above:
231-
1. We load `1.js`, then if there's no error.
232-
2. We load `2.js`, then if there's no error.
231+
1. We load `1.js`, then if there's no error...
232+
2. We load `2.js`, then if there's no error...
233233
3. We load `3.js`, then if there's no error -- do something else `(*)`.
234234

235235
As calls become more nested, the code becomes deeper and increasingly more difficult to manage, especially if we have real code instead of `...` that may include more loops, conditional statements and so on.
@@ -298,7 +298,7 @@ function step3(error, script) {
298298
}
299299
```
300300

301-
See? It does the same, and there's no deep nesting now because we made every action a separate top-level function.
301+
See? It does the same thing, and there's no deep nesting now because we made every action a separate top-level function.
302302

303303
It works, but the code looks like a torn apart spreadsheet. It's difficult to read, and you probably noticed that one needs to eye-jump between pieces while reading it. That's inconvenient, especially if the reader is not familiar with the code and doesn't know where to eye-jump.
304304

1-js/11-async/03-promise-chaining/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ new Promise(function(resolve, reject) {
120120
});
121121
```
122122

123+
<<<<<<< HEAD
123124
Aqui o primeiro `.then` exibe `1` e retorna `new Promise(…)` na linha `(*)`. Após 1 segundo ele é resolvido, e o resultado (o argumento de `resolve`, no caso é `result * 2`) é passado ao tratador do segundo `.then`. O tratador está na linha `(**)`, ele exibe `2` e faz a mesma coisa.
125+
=======
126+
Here the first `.then` shows `1` and returns `new Promise(…)` in the line `(*)`. After one second it resolves, and the result (the argument of `resolve`, here it's `result * 2`) is passed on to the handler of the second `.then`. That handler is in the line `(**)`, it shows `2` and does the same thing.
127+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
124128
125129
Então a saída é a mesma que no exemplo anterior: 1 -> 2 -> 4, mas agora com 1 segundo de atraso entre as chamadas `alert`.
126130

0 commit comments

Comments
 (0)