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
+3-6Lines changed: 3 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,16 +17,13 @@ Inoltre, se state sviluppando in ambiente browser, ci sono ulteriori specifiche
17
17
18
18
## Manuali
19
19
20
-
-**MDN (Mozilla) JavaScript Reference** è un manuale con esempi ed altre informazioni utili. E' ottimo per avere informazioni dettagliate riguardo le funzioni e i metodi del linguaggio.
21
20
22
-
Può essere consultato al link <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
23
-
24
-
Anche se, è meglio eseguire una ricerca internet. E' sufficiente inserire il termine "MDN" nella stringa da ricercare, e.g. <https://google.com/search?q=MDN+parseInt> per ricercare la funzione `parseInt`.
21
+
-**MDN (Mozilla) JavaScript Reference** è il principale manuale con esempi ed altre informazioni utili. E' ottimo per avere informazioni dettagliate riguardo le funzioni e i metodi del linguaggio.
25
22
23
+
Può essere consultato al link <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
26
24
27
-
-**MSDN** – Manuale Microsoft con molte informazioni, incluso JavaScript (a cui viene fatto riferimento con il termine JScript). Se si ha bisongo di ottenere qualche informazione specifica per Internet Explorer, meglio consultare la guida: <http://msdn.microsoft.com/>.
25
+
Sebbene spesso sia meglio eseguire una ricerca internet, è' sufficiente inserire il termine "MDN" nella stringa da ricercare, e.g. <https://google.com/search?q=MDN+parseInt> per ricercare la funzione `parseInt`.
28
26
29
-
Possiamo anche effettuare una ricerca online con frasi come "RegExp MSDN" o "RegExp MSDN jscript".
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
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,21 +16,30 @@ Immaginiamo di dover scrivere 1 milione. La via più ovvia è:
16
16
let billion =1000000000;
17
17
```
18
18
19
+
Possiamo anche usare il carattere underscore `_` come separatore:
20
+
21
+
```js
22
+
let billion =1_000_000_000;
23
+
```
24
+
25
+
Qui il carattere `_` gioca il ruolo di "szucchero sintattico", cioè rende il numero più leggibile. Il motore JavaScript semplicemente ignorerà i caratteri `_` tra le cifre, quindi è come scrive il milione di poco sopra.
26
+
19
27
Nella vita reale però cerchiamo di evitare di scrivere lunghe file di zeri per evitare errori. E anche perché siamo pigri. Solitamente scriviamo qualcosa del tipo `"1ml"` per un milione o `"7.3ml"` 7 milioni e 300mila. Lo stesso vale per i numeri più grandi.
20
28
21
29
In JavaScript, possiamo abbreviare un numero inserendo la lettera `"e"` con il numero di zeri a seguire:
22
30
23
31
```js run
24
32
let billion =1e9; // 1 miliardo, letteralmente: 1 e 9 zeri
25
33
26
-
alert( 7.3e9 ); // 7.3 miliardo (7,300,000,000)
34
+
alert( 7.3e9 ); // 7.3 miliardi (equivale a 7300000000 o 7_300_000_000)
27
35
```
28
36
29
37
In altre parole, `"e"` moltiplica il numero `1` seguito dal numero di zeri dati.
30
38
39
+
31
40
```js
32
-
1e3=1*1000
33
-
1.23e6=1.23*1000000
41
+
1e3=1*1000// e3 means *1000
42
+
1.23e6=1.23*1000000// e6 means *1000000
34
43
```
35
44
36
45
Ora proviamo a scrivere qualcosa di molto piccolo. Ad esempio, 1 microsecondo (un milionesimo di secondo):
@@ -125,7 +134,8 @@ Ci sono diverse funzioni integrate per eseguire questa operazione:
125
134
: Arrotonda per eccesso: `3.1` diventa `4`, e `-1.1` diventa `-1`.
126
135
127
136
`Math.round`
128
-
: Arrotonda all'intero più vicino:`3.1` diventa `3`, `3.6` diventa `4` e `-1.1` diventa `-1`.
137
+
138
+
: Arrotonda all'intero più vicino:`3.1` diventa `3`, `3.6` diventa `4`, e `3.5` viene arrotondato anch'esso a `4`.
129
139
130
140
`Math.trunc` (non supportato da Internet Explorer)
131
141
: Rimuove tutto dopo la virgola decimale senza arrotondare: `3.1` diventa `3`, `-1.1` diventa `-1`.
0 commit comments