You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/01-getting-started/2-manuals-specifications/article.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,21 +13,33 @@ Uma nova versão dessa especificação é lançada todos os anos. Entre estes la
13
13
14
14
Para ler sobre as mais novas funcionalidades (*bleeding-edge features*), incluindo as que estão em fase de padronização (chamadas também de "estágio 3"), veja as suas propostas em <https://github.com/tc39/proposals>.
15
15
16
+
<<<<<<< HEAD
16
17
E mais, se você está desenvolvendo para browsers, há outras especificações que cobrem esta demanda na [segunda parte](info:browser-environment) do tutorial.
18
+
=======
19
+
Also, if you're in developing for the browser, then there are other specifications covered in the [second part](info:browser-environment) of the tutorial.
20
+
>>>>>>> 3a0b3f4e31d4c4bbe90ed4c9c6e676a888ad8311
17
21
18
22
## Manuais
19
23
24
+
<<<<<<< HEAD
20
25
-**MDN (Mozilla) JavaScript Reference** é um manual com exemplos e outras informações. É ótimo para um entendimento sobre funções, métodos da linguagem, etc.
26
+
=======
27
+
-**MDN (Mozilla) JavaScript Reference** is the main manual with examples and other information. It's great to get in-depth information about individual language functions, methods etc.
28
+
>>>>>>> 3a0b3f4e31d4c4bbe90ed4c9c6e676a888ad8311
21
29
22
30
Pode ser encontrado em <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
23
31
32
+
<<<<<<< HEAD
24
33
Porém, às vezes é melhor fazer uma busca na internet. Apenas use "MDN [termo]" na busca, por exemplo: <https://google.com/search?q=MDN+parseInt> para procurar pela função `parseInt`.
25
34
26
35
-**MSDN** - Manual da Microsoft com muitas informações, incluindo JavaScript (frequentemente referido como JScript). Se precisar de algo específico para o Internet Explorer, é melhor ir por aqui: <http://msdn.microsoft.com/>.
27
36
28
37
Assim como para o manual da Mozilla, também podemos fazer uma busca na internet com frases do tipo "RegExp MSDN" ou "RegExp MSDN jscript".
29
38
30
39
## Tabelas de compatibilidade
40
+
=======
41
+
Although, it's often best to use an internet search instead. Just use "MDN [term]" in the query, e.g. <https://google.com/search?q=MDN+parseInt> to search for `parseInt` function.
42
+
>>>>>>> 3a0b3f4e31d4c4bbe90ed4c9c6e676a888ad8311
31
43
32
44
JavaScript é uma linguagem em desenvolvimento, novas funcionalidades são adicionadas regularmente.
Please note: the `?.` syntax makes optional the value before it, but not any further.
105
105
106
-
E.g. in `user?.address.street.name` the `?.` allows `user` to be `null/undefined`, but it's all it does. Further properties are accessed in a regular way. If we want some of them to be optional, then we'll need to replace more `.` with `?.`.
106
+
E.g. in `user?.address.street.name` the `?.` allows `user` to safely be `null/undefined` (and returns `undefined` in that case), but that's only for `user`. Further properties are accessed in a regular way. If we want some of them to be optional, then we'll need to replace more `.` with `?.`.
107
107
108
108
```warn header="Don't overuse the optional chaining"
109
109
We should use `?.` only where it's ok that something doesn't exist.
@@ -173,18 +173,16 @@ Then `?.()` checks the left part: if the admin function exists, then it runs (th
173
173
The `?.[]` syntax also works, if we'd like to use brackets `[]` to access properties instead of dot `.`. Similar to previous cases, it allows to safely read a property from an object that may not exist.
174
174
175
175
```js run
176
+
let key ="firstName";
177
+
176
178
let user1 = {
177
179
firstName:"John"
178
180
};
179
181
180
-
let user2 =null; // Imagine, we couldn't authorize the user
Copy file name to clipboardExpand all lines: 1-js/05-data-types/02-number/article.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,21 +16,29 @@ Imagine we need to write 1 billion. The obvious way is:
16
16
let billion =1000000000;
17
17
```
18
18
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
+
We also can use underscore `_` as the separator:
20
20
21
-
In JavaScript, we shorten a number by appending the letter `"e"` to the number and specifying the zeroes count:
21
+
```js
22
+
let billion =1_000_000_000;
23
+
```
24
+
25
+
Here the underscore `_` plays the role of the "syntactic sugar", it makes the number more readable. The JavaScript engine simply ignores `_` between digits, so it's exactly the same one billion as above.
26
+
27
+
In real life though, we try to avoid writing long sequences of zeroes. We're too lazy for that. We'll try to write something like `"1bn"` for a billion or `"7.3bn"` for 7 billion 300 million. The same is true for most large numbers.
28
+
29
+
In JavaScript, we can shorten a number by appending the letter `"e"` to it and specifying the zeroes count:
22
30
23
31
```js run
24
32
let billion =1e9; // 1 billion, literally: 1 and 9 zeroes
25
33
26
-
alert( 7.3e9 ); // 7.3 billions (7,300,000,000)
34
+
alert( 7.3e9 ); // 7.3 billions (same as 7300000000 or 7_300_000_000)
27
35
```
28
36
29
-
In other words, `"e"` multiplies the number by `1` with the given zeroes count.
37
+
In other words, `e` multiplies the number by `1` with the given zeroes count.
30
38
31
39
```js
32
-
1e3=1*1000
33
-
1.23e6=1.23*1000000
40
+
1e3=1*1000// e3 means *1000
41
+
1.23e6=1.23*1000000// e6 means *1000000
34
42
```
35
43
36
44
Now let's write something very small. Say, 1 microsecond (one millionth of a second):
@@ -125,7 +133,7 @@ There are several built-in functions for rounding:
125
133
: Rounds up:`3.1` becomes `4`, and `-1.1` becomes `-1`.
126
134
127
135
`Math.round`
128
-
: Rounds to the nearest integer:`3.1` becomes `3`, `3.6` becomes `4` and `-1.1` becomes `-1`.
136
+
: Rounds to the nearest integer:`3.1` becomes `3`, `3.6` becomes `4`, the middle case:`3.5` rounds up to `4` too.
129
137
130
138
`Math.trunc` (not supported by Internet Explorer)
131
139
: Removes anything after the decimal point without rounding:`3.1` becomes `3`, `-1.1` becomes `-1`.
0 commit comments