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/04-object-basics/08-symbol/article.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,11 +159,15 @@ for (let key in user) alert(key); // name, age (nessun symbol)
159
159
alert( "Direct: "+ user[id] );
160
160
```
161
161
162
+
<<<<<<< HEAD
162
163
<<<<<<< HEAD
163
164
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.
164
165
=======
165
166
[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.
166
167
>>>>>>> 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
167
171
168
172
Invece [Object.assign](mdn:js/Object/assign) esegue la copia sia delle proprietà di tipo stringa sia di quelle symbol:
Copy file name to clipboardExpand all lines: 1-js/05-data-types/12-json/article.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,11 @@ Fortunatamente, non c'è bisogno di scrivere del codice per gestire questa situa
27
27
28
28
## JSON.stringify
29
29
30
+
<<<<<<< HEAD
30
31
[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.
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
58
62
59
63
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):
60
64
@@ -287,7 +291,11 @@ for(let prop in rabbit) alert(prop); // jumps, then eats
287
291
*/!*
288
292
```
289
293
294
+
<<<<<<< HEAD
290
295
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
291
299
292
300
Quindi possiamo filtrare le proprietà ereditate (o farci qualcos'altro):
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:
Copy file name to clipboardExpand all lines: 5-network/05-fetch-crossorigin/article.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,10 +207,18 @@ Fino a qualche tempo fa nessuno avrebbe potuto supporre che una pagina web fosse
207
207
208
208
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.
209
209
210
+
<<<<<<< HEAD
210
211
Una preflight request usa il method `OPTIONS`, nessun body e due headers:
211
212
212
213
- `Access-Control-Request-Method` che indica il method della unsafe request.
213
214
- `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
214
222
215
223
Se il server accetta di servire la request, invia una risposta con un body vuoto, uno status 200 e le headers:
Un dominio definisce dove il cookie è accessibile. In realtà, ci sono delle limitazioni. Non possiamo impostare nessun dominio.
107
107
108
+
<<<<<<< HEAD
108
109
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`
109
110
110
111
...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
127
128
// su site.com
128
129
// rende il cookie accessibile su ogni sotto dominio *.site.com:
129
130
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:
alert(document.cookie); // possiede un cookie user=John
135
164
```
136
165
166
+
<<<<<<<HEAD
137
167
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.
138
168
139
169
140
170
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
141
176
142
177
## expires, max-age
143
178
@@ -190,7 +225,7 @@ Con questa opzione, se un cookie è impostato su `https://site.com`, non apparir
190
225
//assumendo sia on https:// now
191
226
// imposta il cookie sicuro (Solo accessibile se si utilizza HTTPS)
192
227
document.cookie = "user=John; secure";
193
-
```
228
+
```
194
229
195
230
## samesite
196
231
@@ -257,7 +292,11 @@ Quindi, ciò che `samesite=lax` fa è semplicemente garantire alla più comune o
257
292
258
293
Se questo ti è sufficiente, aggiungere `samesite=lax` probabilmente non intaccherà l'esperienza utente e, allo stesso tempo, aggiungerà protezione.
0 commit comments