Skip to content

Commit 83057ca

Browse files
authored
Merge pull request #357 from javascript-tutorial/sync-3c934b5a
Sync with upstream @ 3c934b5
2 parents f8d5342 + d10056f commit 83057ca

File tree

7 files changed

+72
-1
lines changed

7 files changed

+72
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ In more advanced situations, that we'll come across later, a function may be cre
4343

4444
## Function is a value
4545

46+
<<<<<<< HEAD
4647
Let's reiterate: no matter how the function is created, a function is a value. Both examples above store a function is `sayHi` variable.
4748
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
49+
=======
50+
Let's reiterate: no matter how the function is created, a function is a value. Both examples above store a function in the `sayHi` variable.
51+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
4852
4953
Possiamo anche mostrarne il valore usando `alert`:
5054

1-js/04-object-basics/08-symbol/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,15 @@ for (let key in user) alert(key); // name, age (nessun symbol)
159159
alert( "Direct: " + user[id] );
160160
```
161161

162+
<<<<<<< HEAD
162163
<<<<<<< HEAD
163164
Anche `Object.keys(user)` li ignora. Questo fa parte del principio generale di occultazione delle proprietà symbol. Se uno script esterno o una libreria eseguisse un ciclo sul nostro oggetto, non avrebbe inaspettatamente accesso a una proprietà di tipo symbol.
164165
=======
165166
[Object.keys(user)](mdn:js/Object/keys) also ignores them. That's a part of the general "hiding symbolic properties" principle. If another script or a library loops over our object, it won't unexpectedly access a symbolic property.
166167
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
168+
=======
169+
[Object.keys(user)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys) also ignores them. That's a part of the general "hiding symbolic properties" principle. If another script or a library loops over our object, it won't unexpectedly access a symbolic property.
170+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
167171
168172
Invece [Object.assign](mdn:js/Object/assign) esegue la copia sia delle proprietà di tipo stringa sia di quelle symbol:
169173

1-js/05-data-types/12-json/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ Fortunatamente, non c'è bisogno di scrivere del codice per gestire questa situa
2727

2828
## JSON.stringify
2929

30+
<<<<<<< HEAD
3031
[JSON](http://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation) è un formato per rappresentare valori e oggetti. Viene descritto nello standard [RFC 4627](http://tools.ietf.org/html/rfc4627). Inizialmente fu creato per lavorare con JavaScript, ma molti altri linguaggi possiedono delle librerie per la sua gestione. Quindi JSON risulta semplice da usare per lo scambio di dati quando il client utilizza JavaScript e il server codifica in Ruby/PHP/Java/Altro.
32+
=======
33+
The [JSON](http://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation) is a general format to represent values and objects. It is described as in [RFC 4627](https://tools.ietf.org/html/rfc4627) standard. Initially it was made for JavaScript, but many other languages have libraries to handle it as well. So it's easy to use JSON for data exchange when the client uses JavaScript and the server is written on Ruby/PHP/Java/Whatever.
34+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
3135
3236
JavaScript fornisce i metodi:
3337

1-js/08-prototypes/01-prototype-inheritance/article.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ alert( rabbit.eats ); // true (**)
5454
alert( rabbit.jumps ); // true
5555
```
5656

57+
<<<<<<< HEAD
5758
Nell'esempio la linea `(*)` imposta `animal` come prototype di `rabbit`.
59+
=======
60+
Here the line `(*)` sets `animal` to be the prototype of `rabbit`.
61+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
5862
5963
Successivamente, quando `alert` proverà a leggere la proprietà `rabbit.eats` `(**)`, non la troverà in rabbit, quindi JavaScript seguirà il riferimento in `[[Prototype]]` e la troverà in `animal` (ricerca dal basso verso l'alto):
6064

@@ -287,7 +291,11 @@ for(let prop in rabbit) alert(prop); // jumps, then eats
287291
*/!*
288292
```
289293

294+
<<<<<<< HEAD
290295
Se questo non è ciò che ci aspettiamo, e vogliamo escludere le proprietà ereditate, esiste un metodo integrato [obj.hasOwnProperty(key)](mdn:js/Object/hasOwnProperty): ritorna `true` se `obj` possiede la propria proprietà `key` (non ereditata).
296+
=======
297+
If that's not what we want, and we'd like to exclude inherited properties, there's a built-in method [obj.hasOwnProperty(key)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty): it returns `true` if `obj` has its own (not inherited) property named `key`.
298+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
291299
292300
Quindi possiamo filtrare le proprietà ereditate (o farci qualcos'altro):
293301

1-js/09-classes/01-class/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ alert(Object.getOwnPropertyNames(User.prototype)); // constructor, sayHi
118118

119119
## Non solo una semplificazione (syntax sugar)
120120

121+
<<<<<<< HEAD
121122
Talvolta si pensa che `class` in JavaScript sia solo "syntax sugar" (una sintassi creata per semplificare la lettura, ma che non apporta nulla di nuovo), dato che potremmo potremmo dichiarare la stessa cosa senza utilizzare la parola chiave `class`:
123+
=======
124+
Sometimes people say that `class` is a "syntactic sugar" (syntax that is designed to make things easier to read, but doesn't introduce anything new), because we could actually declare the same thing without using the `class` keyword at all:
125+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
122126
123127
```js run
124128
// la classe User usando solo funzioni

5-network/05-fetch-crossorigin/article.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,18 @@ Fino a qualche tempo fa nessuno avrebbe potuto supporre che una pagina web fosse
207207
208208
Così, per evitare fraintendimenti, per ogni "unsafe" request -- che tempo fa non sarebbero stata possibile, il browser non esegue direttamente queste request. Prima invia una richiesta, chiamata "preflight", per richiedere il permesso.
209209
210+
<<<<<<< HEAD
210211
Una preflight request usa il method `OPTIONS`, nessun body e due headers:
211212
212213
- `Access-Control-Request-Method` che indica il method della unsafe request.
213214
- `Access-Control-Request-Headers` che contiene una lista, separata da virgole, degli unsafe HTTP-headers della request.
215+
=======
216+
A preflight request uses the method `OPTIONS`, no body and three headers:
217+
218+
- `Access-Control-Request-Method` header has the method of the unsafe request.
219+
- `Access-Control-Request-Headers` header provides a comma-separated list of its unsafe HTTP-headers.
220+
- `Origin` header tells from where the request came. (such as `https://javascript.info`)
221+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
214222

215223
Se il server accetta di servire la request, invia una risposta con un body vuoto, uno status 200 e le headers:
216224

6-data-storage/01-cookie/article.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Solitamente, dovremmo impostare `path` nella cartella principale: `path=/` affin
105105

106106
Un dominio definisce dove il cookie è accessibile. In realtà, ci sono delle limitazioni. Non possiamo impostare nessun dominio.
107107

108+
<<<<<<< HEAD
108109
Di default, un cookie è accessibile solo nel dominio in cui è stato impostato. Cosi se il cookie è stato impostato da `site.com`, non lo otterremo su `other.com`
109110

110111
...Inoltre, non otterremo il cookie nel sotto dominio `forum.site.com`!
@@ -127,17 +128,51 @@ Questa è una restrizione per motivi di sicurezza, per consentirci di immagazzin
127128
// su site.com
128129
// rende il cookie accessibile su ogni sotto dominio *.site.com:
129130
document.cookie = "user=John; domain=site.com"
131+
=======
132+
**There's no way to let a cookie be accessible from another 2nd-level domain, so `other.com` will never receive a cookie set at `site.com`.**
133+
134+
It's a safety restriction, to allow us to store sensitive data in cookies that should be available only on one site.
135+
136+
By default, a cookie is accessible only at the domain that set it.
137+
138+
Please note, by default a cookie is also not shared to a subdomain as well, such as `forum.site.com`.
139+
140+
```js
141+
// if we set a cookie at site.com website...
142+
document.cookie = "user=John"
143+
144+
// ...we won't see it at forum.site.com
145+
alert(document.cookie); // no user
146+
```
147+
148+
...But this can be changed. If we'd like to allow subdomains like `forum.site.com` to get a cookie set at `site.com`, that's possible.
149+
150+
For that to happen, when setting a cookie at `site.com`, we should explicitly set the `domain` option to the root domain: `domain=site.com`. Then all subdomains will see such cookie.
151+
152+
For example:
153+
154+
```js
155+
// at site.com
156+
// make the cookie accessible on any subdomain *.site.com:
157+
document.cookie = "user=John; *!*domain=site.com*/!*"
158+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
130159
131160
// dopo
132161
133162
// su forum.site.com
134163
alert(document.cookie); // possiede un cookie user=John
135164
```
136165

166+
<<<<<<< HEAD
137167
Per ragioni storiche, `domain=.site.com` (un punto prima di `site.com`) funziona nello stesso modo, garantendo accesso al cookie dal sotto dominio. Questa è una vecchia notazione, dovrebbe essere utilizzata se dobbiamo supportare vecchi browsers.
138168

139169

140170
Ricapitolando, l'opzione `domain` ci consente di rendere un cookie accessibile ai sotto domini.
171+
=======
172+
For historical reasons, `domain=.site.com` (with a dot before `site.com`) also works the same way, allowing access to the cookie from subdomains. That's an old notation and should be used if we need to support very old browsers.
173+
174+
To summarize, the `domain` option allows to make a cookie accessible at subdomains.
175+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
141176

142177
## expires, max-age
143178

@@ -190,7 +225,7 @@ Con questa opzione, se un cookie è impostato su `https://site.com`, non apparir
190225
//assumendo sia on https:// now
191226
// imposta il cookie sicuro (Solo accessibile se si utilizza HTTPS)
192227
document.cookie = "user=John; secure";
193-
```
228+
```
194229

195230
## samesite
196231

@@ -257,7 +292,11 @@ Quindi, ciò che `samesite=lax` fa è semplicemente garantire alla più comune o
257292
258293
Se questo ti è sufficiente, aggiungere `samesite=lax` probabilmente non intaccherà l'esperienza utente e, allo stesso tempo, aggiungerà protezione.
259294

295+
<<<<<<< HEAD
260296
Generalmente, `samesite` è un'ottima scelta.
297+
=======
298+
Overall, `samesite` is a great option.
299+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
261300
262301
Ma c'è uno svantaggio:
263302

0 commit comments

Comments
 (0)