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/08-prototypes/03-native-prototypes/article.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,33 @@
1
-
# Native prototypes
1
+
# Нативные прототипы
2
2
3
-
The`"prototype"`property is widely used by the core of JavaScript itself. All built-in constructor functions use it.
3
+
Свойство`"prototype"`широко используется в самом ядре JavaScript. Все встроенные функции-конструкторы используют его.
4
4
5
-
We'll see how it is for plain objects first, and then for more complex ones.
5
+
Сначала мы посмотрим как это работает для простых объектов, а затем и для более сложных.
6
6
7
7
## Object.prototype
8
8
9
-
Let's say we output an empty object:
9
+
Давайте выведем пустой объект:
10
10
11
11
```js run
12
12
let obj = {};
13
13
alert( obj ); // "[object Object]" ?
14
14
```
15
15
16
-
Where's the code that generates the string `"[object Object]"`? That's a built-in`toString` method, but where is it? The `obj`is empty!
16
+
Где код, который генерирует строку `"[object Object]"`? Это встроенный метод`toString`, но где он? `obj`ведь пуст!
17
17
18
-
...But the short notation `obj = {}`is the same as `obj = new Object()`, where`Object`is a built-in object constructor function, with its own `prototype` referencing a huge object with `toString`and other methods.
18
+
...Но краткая нотация `obj = {}`это тоже самое, что и `obj = new Object()`, где`Object`- встроенная функция-конструктор для объектов с собственным свойством `prototype`, который ссылается на огромный объект с методом `toString`и другими.
19
19
20
-
Here's what's going on:
20
+
Вот что происходит:
21
21
22
22

23
23
24
-
When `new Object()`is called (or a literal object`{...}` is created), the`[[Prototype]]`of it is set to `Object.prototype`according to the rule that we discussed in the previous chapter:
24
+
Когда вызывается `new Object()`(или создается объект с помощью литерала`{...}`), свойство`[[Prototype]]`этого объекта устанавливается как `Object.prototype`по правилам, который мы обсуждали в предыдущей статье:
25
25
26
26

27
27
28
-
So then when `obj.toString()`is called the method is taken from`Object.prototype`.
28
+
Таким образом, когда вызывается `obj.toString()`метод берется из`Object.prototype`.
0 commit comments