|
1 | 1 |
|
2 |
| -We can see which class it belongs by outputting it, like: |
| 2 | +আমরা এভাবে এর ক্লাস নামটি দেখতে পারি: |
3 | 3 |
|
4 | 4 | ```js run
|
5 | 5 | alert(document); // [object HTMLDocument]
|
6 | 6 | ```
|
7 | 7 |
|
8 |
| -Or: |
| 8 | +অথবা: |
9 | 9 |
|
10 | 10 | ```js run
|
11 | 11 | alert(document.constructor.name); // HTMLDocument
|
12 | 12 | ```
|
13 | 13 |
|
14 |
| -So, `document` is an instance of `HTMLDocument` class. |
| 14 | +সুতরাং, `document` হল `HTMLDocument` ক্লাসের ইন্সট্যান্স। |
15 | 15 |
|
16 |
| -What's its place in the hierarchy? |
| 16 | +চলুন হায়ার্য়াকি অনুযায়ী আরো বিস্তারিত দেখি |
17 | 17 |
|
18 |
| -Yeah, we could browse the specification, but it would be faster to figure out manually. |
| 18 | +আমরা স্পেসিফিকেশন দেখে এই ব্যাপারে জানতে পারি, কিন্তু আমরা কোড করেও এর বিস্তারিত দেখতে পারি। |
19 | 19 |
|
20 |
| -Let's traverse the prototype chain via `__proto__`. |
| 20 | +চলুন আমরা `__proto__` প্রটোটাইপ চেইন ট্রাভার্স করি। |
21 | 21 |
|
22 |
| -As we know, methods of a class are in the `prototype` of the constructor. For instance, `HTMLDocument.prototype` has methods for documents. |
| 22 | +আমরা জানি, ক্লাসের মেথডসমূহ `prototype` দ্বারা constructor কে নির্দেশিত করে। যেমন, `HTMLDocument.prototype` এ ডকুমেন্ট এর মেথড আছে। |
23 | 23 |
|
24 |
| -Also, there's a reference to the constructor function inside the `prototype`: |
| 24 | +এছাড়াও, `prototype` এর constructor এ এর উল্লেখ আছে: |
25 | 25 |
|
26 | 26 | ```js run
|
27 | 27 | alert(HTMLDocument.prototype.constructor === HTMLDocument); // true
|
28 | 28 | ```
|
29 | 29 |
|
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 | +ক্লাস নামটিকে কে আমরা স্ট্রিং আকারে পেতে, `constructor.name` ব্যবহার করতে পারি। চলুন আমরা `document` এর প্রটোটাইপ চেইন ট্রাভার্স করি, যতক্ষণ পর্যন্ত `Node` ক্লাসটি না পায়: |
31 | 31 |
|
32 | 32 | ```js run
|
33 | 33 | alert(HTMLDocument.prototype.constructor.name); // HTMLDocument
|
34 | 34 | alert(HTMLDocument.prototype.__proto__.constructor.name); // Document
|
35 | 35 | alert(HTMLDocument.prototype.__proto__.__proto__.constructor.name); // Node
|
36 | 36 | ```
|
37 | 37 |
|
38 |
| -That's the hierarchy. |
| 38 | +এটিই document এর হায়ার্য়াকি। |
39 | 39 |
|
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 | +আমরা `console.dir(document)` এর সাহায্যেও দেখতে পারি, এবং `__proto__` তে ক্লিক করে প্রত্যেকটির নাম দেখতে পাব। কনসোল ইন্টার্নালি `constructor` সমূহ নেয়। |
0 commit comments