Skip to content

Commit e1acbae

Browse files
committed
Translate Object.prototype part
1 parent 7b37e60 commit e1acbae

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

1-js/08-prototypes/03-native-prototypes/article.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# Native prototypes
1+
# Нативные прототипы
22

3-
The `"prototype"` property is widely used by the core of JavaScript itself. All built-in constructor functions use it.
3+
Свойство `"prototype"` широко используется в самом ядре JavaScript. Все встроенные функции-конструкторы используют его.
44

5-
We'll see how it is for plain objects first, and then for more complex ones.
5+
Сначала мы посмотрим как это работает для простых объектов, а затем и для более сложных.
66

77
## Object.prototype
88

9-
Let's say we output an empty object:
9+
Давайте выведем пустой объект:
1010

1111
```js run
1212
let obj = {};
1313
alert( obj ); // "[object Object]" ?
1414
```
1515

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` ведь пуст!
1717

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` и другими.
1919

20-
Here's what's going on:
20+
Вот что происходит:
2121

2222
![](object-prototype.png)
2323

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` по правилам, который мы обсуждали в предыдущей статье:
2525

2626
![](object-prototype-1.png)
2727

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

30-
We can check it like this:
30+
Мы можем проверить это так:
3131

3232
```js run
3333
let obj = {};
@@ -36,7 +36,7 @@ alert(obj.__proto__ === Object.prototype); // true
3636
// obj.toString === obj.__proto__.toString == Object.prototype.toString
3737
```
3838

39-
Please note that there is no additional `[[Prototype]]` in the chain above `Object.prototype`:
39+
Стоит обратить внимание, что выше `Object.prototype` по цепочке прототипов нет допольнительного свойства `[[Prototype]]`:
4040

4141
```js run
4242
alert(Object.prototype.__proto__); // null

0 commit comments

Comments
 (0)