Skip to content

Commit a762122

Browse files
committed
Translate Task 1
1 parent dd66dea commit a762122

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
The method can take all enumerable keys using `Object.keys` and output their list.
2+
В методе можно получить список всех перечисляем ключей с помощью `Object.keys` и вывести их как список.
33

4-
To make `toString` non-enumerable, let's define it using a property descriptor. The syntax of `Object.create` allows us to provide an object with property descriptors as the second argument.
4+
Чтобы сделать `toString` не перечисляемым, давайте определим метод как дескриптор свойства. Синтаксис `Object.create` позволяет нам добавить в объект дескрипторы свойств как второй аргумент.
55

66
```js run
77
*!*
88
let dictionary = Object.create(null, {
9-
toString: { // define toString property
10-
value() { // the value is a function
9+
toString: { // определяем свойство toString
10+
value() { // значение -- это функция
1111
return Object.keys(this).join();
1212
}
1313
}
@@ -17,15 +17,15 @@ let dictionary = Object.create(null, {
1717
dictionary.apple = "Apple";
1818
dictionary.__proto__ = "test";
1919

20-
// apple and __proto__ is in the loop
20+
// apple и __proto__ выведены в цикле
2121
for(let key in dictionary) {
22-
alert(key); // "apple", then "__proto__"
22+
alert(key); // "apple", затем "__proto__"
2323
}
2424

25-
// comma-separated list of properties by toString
25+
// список свойств разделённых запятой выведен с помощью toString
2626
alert(dictionary); // "apple,__proto__"
2727
```
2828

29-
When we create a property using a descriptor, its flags are `false` by default. So in the code above, `dictionary.toString` is non-enumerable.
29+
Когда мы создаем свойство с помощью дескриптора, все флаги по умолчанию имеют значение `false`. Таким образом, в коде выше `dictionary.toString` не перечисляемое свойство.
3030

31-
See the the chapter [](info:property-descriptors) for review.
31+
Смотрите главу [](info:property-descriptors) для ознакомления.

1-js/08-prototypes/04-prototype-methods/2-dictionary-tostring/task.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ importance: 5
22

33
---
44

5-
# Add toString to the dictionary
5+
# Добавьте toString в словарь
66

7-
There's an object `dictionary`, created as `Object.create(null)`, to store any `key/value` pairs.
7+
Имеется объект `dictionary`, созданный с помощью `Object.create(null)` для хранения любых пар `ключ/значение`.
88

9-
Add method `dictionary.toString()` into it, that should return a comma-delimited list of keys. Your `toString` should not show up in `for..in` over the object.
9+
Добавьте ему метод `dictionary.toString()`, который должен возвращать список ключей разделенных запятой. Ваш `toString` не должен выводиться при итерации объекта с помощью цикла `for..in`.
1010

11-
Here's how it should work:
11+
Вот так это должно работать:
1212

1313
```js
1414
let dictionary = Object.create(null);
1515

1616
*!*
17-
// your code to add dictionary.toString method
17+
// ваш код для добавляет метод dictionary.toString
1818
*/!*
1919

20-
// add some data
20+
// добавляем немного данных
2121
dictionary.apple = "Apple";
22-
dictionary.__proto__ = "test"; // __proto__ is a regular property key here
22+
dictionary.__proto__ = "test"; // здесь __proto__ -- это обычный ключ
2323

24-
// only apple and __proto__ are in the loop
24+
// только apple и __proto__ выведен в цикле
2525
for(let key in dictionary) {
26-
alert(key); // "apple", then "__proto__"
26+
alert(key); // "apple", затем "__proto__"
2727
}
2828

29-
// your toString in action
29+
// ваш метод toString в действии
3030
alert(dictionary); // "apple,__proto__"
3131
```

0 commit comments

Comments
 (0)