Skip to content

Commit 7682922

Browse files
committed
Update 2-ui/1-document/05-basic-dom-node-properties
1 parent 340a4c6 commit 7682922

File tree

2 files changed

+12
-12
lines changed
  • 2-ui/1-document/05-basic-dom-node-properties/4-where-document-in-hierarchy

2 files changed

+12
-12
lines changed
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11

2-
We can see which class it belongs by outputting it, like:
2+
Possiamo visualizzare a quale classe appartiene in questo modo:
33

44
```js run
55
alert(document); // [object HTMLDocument]
66
```
77

8-
Or:
8+
Oppure:
99

1010
```js run
1111
alert(document.constructor.name); // HTMLDocument
1212
```
1313

14-
So, `document` is an instance of `HTMLDocument` class.
14+
Quindi `document` è un'istanza della classe `HTMLDocument`.
1515

16-
What's its place in the hierarchy?
16+
Qual è il suo posto nella gerarchia DOM?
1717

18-
Yeah, we could browse the specification, but it would be faster to figure out manually.
18+
Certo, potremmo sfogliare la specifica, ma sarebbe più veloce scoprirlo manualmente.
1919

20-
Let's traverse the prototype chain via `__proto__`.
20+
Attraversiamo la catena dei prototipi tramite `__proto__`.
2121

22-
As we know, methods of a class are in the `prototype` of the constructor. For instance, `HTMLDocument.prototype` has methods for documents.
22+
Come sappiamo i metodi di una classe sono nel `prototype` del costruttore. Per esempio `HTMLDocument.prototype` ha i metodi per i documenti.
2323

24-
Also, there's a reference to the constructor function inside the `prototype`:
24+
C'è inoltre un riferimento al costruttore all'interno di `prototype`:
2525

2626
```js run
2727
alert(HTMLDocument.prototype.constructor === HTMLDocument); // true
2828
```
2929

30-
To get a name of the class as a string, we can use `constructor.name`. Let's do it for the whole `document` prototype chain, till class `Node`:
30+
Per ricavare la stringa con il nome della classe possiamo usare `constructor.name`. Facciamolo per l'intera catena prototipale `document` fino alla classe` Node`:
3131

3232
```js run
3333
alert(HTMLDocument.prototype.constructor.name); // HTMLDocument
3434
alert(HTMLDocument.prototype.__proto__.constructor.name); // Document
3535
alert(HTMLDocument.prototype.__proto__.__proto__.constructor.name); // Node
3636
```
3737

38-
That's the hierarchy.
38+
Questa è la gerachia.
3939

40-
We also could examine the object using `console.dir(document)` and see these names by opening `__proto__`. The console takes them from `constructor` internally.
40+
Potremmo anche esaminare l'oggetto usando `console.dir(document)` e visualizzare gli stessi nomi aprendo `__proto__`. La console li ricava internamente da `constructor`.

2-ui/1-document/05-basic-dom-node-properties/4-where-document-in-hierarchy/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ A quale classe appartiene `document`?
88

99
Qual è il suo posto nella gerarchia DOM?
1010

11-
Does it inherit from `Node` or `Element`, or maybe `HTMLElement`?
11+
Eredita da `Node`, da `Element` o forse da `HTMLElement`?

0 commit comments

Comments
 (0)