Skip to content

Commit 20ef46b

Browse files
authored
Merge branch 'master' into 17-regexp-methods
2 parents 0f1f4fb + 7d1dc8a commit 20ef46b

File tree

25 files changed

+363
-383
lines changed

25 files changed

+363
-383
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ Exemplos de tais linguagens:
109109
- [CoffeeScript](http://coffeescript.org/) é um "açúcar sintático" para JavaScript. Ele introduz uma sintaxe mais curta, permitindo-nos escrever um código mais claro e preciso. Normalmente, Ruby devs gostam dele.
110110
- [TypeScript](http://www.typescriptlang.org/) está concentrado em adicionar "estritos tipos de dados" para simplificar o desenvolvimento e suporte de sistemas complexos. É desenvolvido pela Microsoft.
111111
- [Flow](http://flow.org/) também adiciona tipos de dados, mas de uma forma diferente. Desenvolvido pela Facebook.
112-
- [Dart](https://www.dartlang.org/) é uma linguagem autônoma que tem seu próprio interpretador que roda em ambientes fora do navegador (como aplicativos móveis), mas também pode ser transpilada para JavaScript. Desenvolvido pela Google.
112+
- [Dart](https://www.dartlang.org/) é uma linguagem autônoma que tem seu próprio interpretador que roda em ambientes fora do navegador (como aplicativos móveis), mas também pode ser transpilada para JavaScript. Desenvolvida pela Google.
113113
- [Brython](https://brython.info/) é um transpilador de Python para JavaScript que permite escrever aplicativos em puro Python, sem JavaScript.
114+
- [Kotlin](https://kotlinlang.org/docs/js-overview.html) é uma linguagem de programação moderna, concisa e segura, que pode ser usada no navegador ou no Node.
114115

115116
Há mais. Claro que, mesmo que usemos uma dessas linguagens transpiladas, também devemos saber JavaScript para entender o que estamos fazendo.
116117

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
JavaScript-code:
1+
Código Javascript:
22

33
```js demo run
4-
let name = prompt("What is your name?", "");
4+
let name = prompt("Qual o seu nome?", "");
55
alert(name);
66
```
77

8-
The full page:
8+
Página completa:
99

1010
```html
1111
<!DOCTYPE html>
1212
<html>
1313
<body>
1414

15-
<script>
16-
'use strict';
15+
<script>
16+
'use strict';
1717
18-
let name = prompt("What is your name?", "");
19-
alert(name);
20-
</script>
18+
let name = prompt("Qual o seu nome?", "");
19+
alert(name);
20+
</script>
2121

22-
</body>
22+
</body>
2323
</html>
2424
```

1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ importance: 4
22

33
---
44

5-
# A simple page
5+
# Uma página simples
66

7-
Create a web-page that asks for a name and outputs it.
7+
Crie uma página web que solicite um nome e o exiba.
88

99
[demo]
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,105 @@
1-
# Interaction: alert, prompt, confirm
1+
# Interação: alert, prompt, confirm
22

3-
As we'll be using the browser as our demo environment, let's see a couple of functions to interact with the user: `alert`, `prompt` and `confirm`.
3+
Como usuaremos o navegador como nosso ambiente de demonstração, vamos ver algumas funções para interagir com o usuário: `alert`, `prompt` e `confirm`.
44

55
## alert
66

7-
This one we've seen already. It shows a message and waits for the user to press "OK".
7+
Esta já vimos. Ela mostra uma mensagem e aguarda o usuário pressionar "OK".
88

9-
For example:
9+
Por exemplo:
1010

1111
```js run
12-
alert("Hello");
12+
alert('Olá');
1313
```
1414

15-
The mini-window with the message is called a *modal window*. The word "modal" means that the visitor can't interact with the rest of the page, press other buttons, etc, until they have dealt with the window. In this case -- until they press "OK".
15+
A mini-janela com a mensagem é chamada de _modal window_. A palavra "modal" significa que o visitante não pode interagir com o resto da página, pressionar outros botões, etc, até que ele tenha lidado com a janela. Nesse caso -- até pressionar "OK".
1616

1717
## prompt
1818

19-
The function `prompt` accepts two arguments:
19+
A função `prompt` aceita dois argumentos:
2020

2121
```js no-beautify
2222
result = prompt(title, [default]);
2323
```
2424

25-
It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel.
25+
Mostra uma janela modal com uma mensagem de texto, um campo de entrada para o visitante, e os botões OK/Cancel.
2626

2727
`title`
28-
: The text to show the visitor.
28+
: Texto para ser mostrado ao visitante.
2929

3030
`default`
31-
: An optional second parameter, the initial value for the input field.
31+
: Um parâmetro opcional, o valor inicial para o campo de entrada.
3232

33-
```smart header="The square brackets in syntax `[...]`"
34-
The square brackets around `default` in the syntax above denote that the parameter is optional, not required.
35-
```
33+
```smart header="Os colchetes na sintaxe `[...]`"
34+
Os colchetes ao redor de `default` na sintaxe acima denotam que o parâmetro é opcional, não é obrigatório.
35+
````
3636
37-
The visitor can type something in the prompt input field and press OK. Then we get that text in the `result`. Or they can cancel the input by pressing Cancel or hitting the `key:Esc` key, then we get `null` as the `result`.
37+
O visitante pode digitar algo no campo de entrada do prompt e pressionar OK. Então nós temos esse texto no `result`. Ou ele pode cancelar a entrada pressionando Cancelar ou `key:Esc`, então nos temos `null` como o `result`.
3838
39-
The call to `prompt` returns the text from the input field or `null` if the input was canceled.
39+
A chamada do `prompt` retorna o texto do campo de entrada ou `null` se a entrada for cancelada.
4040
41-
For instance:
41+
Por exemplo:
4242
4343
```js run
44-
let age = prompt('How old are you?', 100);
44+
let age = prompt('Qual a sua idade?', 100);
4545
46-
alert(`You are ${age} years old!`); // You are 100 years old!
47-
```
46+
alert(`Você tem ${age} anos!`); //Você tem 100 anos!
47+
````
4848

49-
````warn header="In IE: always supply a `default`"
50-
The second parameter is optional, but if we don't supply it, Internet Explorer will insert the text `"undefined"` into the prompt.
49+
````warn header="No IE: sempre forneça um `default`"
50+
O segundo parâmetro é opcional, mas se não o fornecermos, o Internet Explorer irá inserir o texto `"undefined"` no prompt.
5151

52-
Run this code in Internet Explorer to see:
52+
Execute este código no Internet Explorer para visualizar:
5353

5454
```js run
55-
let test = prompt("Test");
55+
let test = prompt('Teste');
5656
```
5757

58-
So, for prompts to look good in IE, we recommend always providing the second argument:
58+
Portanto, para que os prompts tenham boa aparência no IE, recomendamos que sempre forneça o segundo argumento:
5959

6060
```js run
61-
let test = prompt("Test", ''); // <-- for IE
61+
let test = prompt('Teste', ''); // <-- para o IE
6262
```
6363
````
6464
6565
## confirm
6666
67-
The syntax:
67+
A sintaxe:
6868
6969
```js
7070
result = confirm(question);
7171
```
7272
73-
The function `confirm` shows a modal window with a `question` and two buttons: OK and Cancel.
73+
A função `confirm` mostra uma janela modal com uma `question` e dois botões: OK e Cancelar.
7474
75-
The result is `true` if OK is pressed and `false` otherwise.
75+
O resultado é `true` se OK for pressionado e `false` caso contrário.
7676
77-
For example:
77+
Por exemplo:
7878
7979
```js run
80-
let isBoss = confirm("Are you the boss?");
80+
let isBoss = confirm("Você é o chefe?");
8181
82-
alert( isBoss ); // true if OK is pressed
82+
alert( isBoss ); // true se OK for pressionado
8383
```
8484
85-
## Summary
85+
## Sumário
8686
87-
We covered 3 browser-specific functions to interact with visitors:
87+
Cobrimos 3 funções específicas do navegador para interagir com o visitante:
8888
8989
`alert`
90-
: shows a message.
90+
: mostra uma mensagem.
9191
9292
`prompt`
93-
: shows a message asking the user to input text. It returns the text or, if Cancel button or `key:Esc` is clicked, `null`.
93+
: mostra uma mensagem pedindo para o usuário inserir texto. Ela retorna o texto ou, se CANCEL ou `key:Esc` for clicado, `null`.
9494
9595
`confirm`
96-
: shows a message and waits for the user to press "OK" or "Cancel". It returns `true` for OK and `false` for Cancel/`key:Esc`.
96+
: mostra uma mensagem e espera que o usuário pressione "OK" ou "Cancel". Ela retorna `true` para OK e `false` para Cancel/`key:Esc`.
9797
98-
All these methods are modal: they pause script execution and don't allow the visitor to interact with the rest of the page until the window has been dismissed.
98+
Todos esse métodos são modais: eles pausam a execução do script e não permitem ao visitante interagir com o resto da página até que a janela seja descartada.
9999
100-
There are two limitations shared by all the methods above:
100+
Existem duas limitações compartilhadas entre esses metódos acima:
101101
102-
1. The exact location of the modal window is determined by the browser. Usually, it's in the center.
103-
2. The exact look of the window also depends on the browser. We can't modify it.
102+
1. A localização exata da janela modal é determinada pelo navegador. Geralmente, está no centro.
103+
2. A aparência exata da janela também depende do navegador. Nós não podemos modificá-la.
104104
105-
That is the price for simplicity. There are other ways to show nicer windows and richer interaction with the visitor, but if "bells and whistles" do not matter much, these methods work just fine.
105+
Este é o preço da simplicidade. Existem outras maneiras de mostrar janelas mais agradáveis e interações mais ricas aos visitantes, mas se "sinos e assobios" não importam muito, esses métodos funcionam bem.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ alert( x ); // 5
219219
220220
The fact of `=` being an operator, not a "magical" language construct has an interesting implication.
221221
222-
Most operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.
222+
All operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.
223223

224224
The call `x = value` writes the `value` into `x` *and then returns it*.
225225

1-js/02-first-steps/18-javascript-specials/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ We covered three ways to create a function in JavaScript:
273273
```
274274
275275
276-
- Functions may have local variables: those declared inside its body. Such variables are only visible inside the function.
276+
- Functions may have local variables: those declared inside its body or its parameter list. Such variables are only visible inside the function.
277277
- Parameters can have default values: `function sum(a = 1, b = 2) {...}`.
278278
- Functions always return something. If there's no `return` statement, then the result is `undefined`.
279279

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Existem botões para isso no topo do painel direito. Vamos interagir com eles.
135135
Continuando a clicar nele, passará por todas as instruções do programa, uma por uma.
136136

137137
<span class="devtools" style="background-position:-62px -192px"></span> -- "Step over": execute o próximo comando, mas *mas não vá para dentro de uma função*, atalho `key:F10`.
138-
: Similar ao comando "Step" anterior, mas com um comportamento diferente se a próxima instrução for uma chamada de função. Isto é: não uma incorporada (*built-in*), como `alert`, mas uma função sua.
138+
: Similar ao comando "Step" anterior, mas com um comportamento diferente se a próxima instrução for uma chamada de função. Isto é: não uma incorporada (*built-in*), como `alert`, mas uma função nossa.
139139

140140
O comando "Step", vai para dentro dela e suspende a execução na sua primeira linha, ao contrário de "Step over" que executa essa chamada de função aninhada invisívelmente, saltando sobre o funcionamento interno da função.
141141

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,4 @@ As we can see, all of them are straightforward and simple to use. The `?.` check
219219
220220
A chain of `?.` allows to safely access nested properties.
221221
222-
Still, we should apply `?.` carefully, only where it's acceptable that the left part doesn't to exist. So that it won't hide programming errors from us, if they occur.
222+
Still, we should apply `?.` carefully, only where it's acceptable that the left part doesn't exist. So that it won't hide programming errors from us, if they occur.

1-js/05-data-types/02-number/article.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Imagine we need to write 1 billion. The obvious way is:
1616
let billion = 1000000000;
1717
```
1818

19-
But in real life we usually avoid writing a long string of zeroes as it's easy to mistype. Also, we are lazy. We will usually write something like `"1bn"` for a billion or `"7.3bn"` for 7 billion 300 million. The same is true for most large numbers.
19+
But in real life, we usually avoid writing a long string of zeroes as it's easy to mistype. Also, we are lazy. We will usually write something like `"1bn"` for a billion or `"7.3bn"` for 7 billion 300 million. The same is true for most large numbers.
2020

2121
In JavaScript, we shorten a number by appending the letter `"e"` to the number and specifying the zeroes count:
2222

@@ -180,7 +180,7 @@ There are two ways to do so:
180180

181181
## Imprecise calculations
182182

183-
Internally, a number is represented in 64-bit format [IEEE-754](http://en.wikipedia.org/wiki/IEEE_754-1985), so there are exactly 64 bits to store a number: 52 of them are used to store the digits, 11 of them store the position of the decimal point (they are zero for integer numbers), and 1 bit is for the sign.
183+
Internally, a number is represented in 64-bit format [IEEE-754](https://en.wikipedia.org/wiki/IEEE_754-2008_revision), so there are exactly 64 bits to store a number: 52 of them are used to store the digits, 11 of them store the position of the decimal point (they are zero for integer numbers), and 1 bit is for the sign.
184184

185185
If a number is too big, it would overflow the 64-bit storage, potentially giving an infinity:
186186

@@ -208,15 +208,15 @@ Ouch! There are more consequences than an incorrect comparison here. Imagine you
208208

209209
But why does this happen?
210210

211-
A number is stored in memory in its binary form, a sequence of ones and zeroes. But fractions like `0.1`, `0.2` that look simple in the decimal numeric system are actually unending fractions in their binary form.
211+
A number is stored in memory in its binary form, a sequence of bits - ones and zeroes. But fractions like `0.1`, `0.2` that look simple in the decimal numeric system are actually unending fractions in their binary form.
212212

213213
In other words, what is `0.1`? It is one divided by ten `1/10`, one-tenth. In decimal numeral system such numbers are easily representable. Compare it to one-third: `1/3`. It becomes an endless fraction `0.33333(3)`.
214214

215215
So, division by powers `10` is guaranteed to work well in the decimal system, but division by `3` is not. For the same reason, in the binary numeral system, the division by powers of `2` is guaranteed to work, but `1/10` becomes an endless binary fraction.
216216

217217
There's just no way to store *exactly 0.1* or *exactly 0.2* using the binary system, just like there is no way to store one-third as a decimal fraction.
218218

219-
The numeric format IEEE-754 solves this by rounding to the nearest possible number. These rounding rules normally don't allow us to see that "tiny precision loss", so the number shows up as `0.3`. But beware, the loss still exists.
219+
The numeric format IEEE-754 solves this by rounding to the nearest possible number. These rounding rules normally don't allow us to see that "tiny precision loss", but it exists.
220220

221221
We can see this in action:
222222
```js run
@@ -327,7 +327,7 @@ Please note that an empty or a space-only string is treated as `0` in all numeri
327327
There is a special built-in method [`Object.is`](mdn:js/Object/is) that compares values like `===`, but is more reliable for two edge cases:
328328

329329
1. It works with `NaN`: `Object.is(NaN, NaN) === true`, that's a good thing.
330-
2. Values `0` and `-0` are different: `Object.is(0, -0) === false`, it rarely matters, but these values technically are different.
330+
2. Values `0` and `-0` are different: `Object.is(0, -0) === false`, technically that's true, because internally the number has a sign bit that may be different even if all other bits are zeroes.
331331

332332
In all other cases, `Object.is(a, b)` is the same as `a === b`.
333333

@@ -383,7 +383,7 @@ JavaScript has a built-in [Math](https://developer.mozilla.org/en/docs/Web/JavaS
383383
A few examples:
384384

385385
`Math.random()`
386-
: Returns a random number from 0 to 1 (not including 1)
386+
: Returns a random number from 0 to 1 (not including 1).
387387

388388
```js run
389389
alert( Math.random() ); // 0.1234567894322
@@ -400,7 +400,7 @@ A few examples:
400400
```
401401

402402
`Math.pow(n, power)`
403-
: Returns `n` raised the given power
403+
: Returns `n` raised to the given power.
404404

405405
```js run
406406
alert( Math.pow(2, 10) ); // 2 in power 10 = 1024

0 commit comments

Comments
 (0)