diff --git a/1-js/09-classes/03-static-properties-methods/3-class-extend-object/solution.md b/1-js/09-classes/03-static-properties-methods/3-class-extend-object/solution.md
index ca9e80601..2bdfd261b 100644
--- a/1-js/09-classes/03-static-properties-methods/3-class-extend-object/solution.md
+++ b/1-js/09-classes/03-static-properties-methods/3-class-extend-object/solution.md
@@ -1,14 +1,14 @@
-First, let's see why the latter code doesn't work.
+Спочатку подивімося, чому останній код не працює.
-The reason becomes obvious if we try to run it. An inheriting class constructor must call `super()`. Otherwise `"this"` won't be "defined".
+Причина стає очевидною, якщо ми спробуємо його запустити. Конструктор класу, що успадковується, повинен викликати `super()`. Інакше `"this"` буде не визначене.
-So here's the fix:
+Виправлення:
```js run
class Rabbit extends Object {
constructor(name) {
*!*
- super(); // need to call the parent constructor when inheriting
+ super(); // потрібно викликати батьківський конструктор під час успадкування
*/!*
this.name = name;
}
@@ -19,16 +19,16 @@ let rabbit = new Rabbit("Rab");
alert( rabbit.hasOwnProperty('name') ); // true
```
-But that's not all yet.
+Але це ще не все.
-Even after the fix, there's still important difference in `"class Rabbit extends Object"` versus `class Rabbit`.
+Навіть після виправлення все ще існує важлива різниця між `"class Rabbit extends Object"` та `class Rabbit`.
-As we know, the "extends" syntax sets up two prototypes:
+Як ми знаємо, синтаксис "extends" встановлює два прототипи:
-1. Between `"prototype"` of the constructor functions (for methods).
-2. Between the constructor functions themselves (for static methods).
+1. Між `"prototype"` функцій-конструкторів (для методів).
+2. Між самими функціями-конструкторами (для статичних методів).
-In our case, for `class Rabbit extends Object` it means:
+У нашому випадку для `class Rabbit extends Object` це означає:
```js run
class Rabbit extends Object {}
@@ -37,45 +37,45 @@ alert( Rabbit.prototype.__proto__ === Object.prototype ); // (1) true
alert( Rabbit.__proto__ === Object ); // (2) true
```
-So `Rabbit` now provides access to static methods of `Object` via `Rabbit`, like this:
+Отже, `Rabbit` тепер надає доступ до статичних методів `Object` через `Rabbit`, наприклад:
```js run
class Rabbit extends Object {}
*!*
-// normally we call Object.getOwnPropertyNames
+// зазвичай ми викликаємо Object.getOwnPropertyNames
alert ( Rabbit.getOwnPropertyNames({a: 1, b: 2})); // a,b
*/!*
```
-But if we don't have `extends Object`, then `Rabbit.__proto__` is not set to `Object`.
+Але якщо у нас немає `extends Object`, тоді для `Rabbit.__proto__` не встановлено значення `Object`.
-Here's the demo:
+Приклад:
```js run
class Rabbit {}
alert( Rabbit.prototype.__proto__ === Object.prototype ); // (1) true
alert( Rabbit.__proto__ === Object ); // (2) false (!)
-alert( Rabbit.__proto__ === Function.prototype ); // as any function by default
+alert( Rabbit.__proto__ === Function.prototype ); // як у будь-якої функції за замовчуванням
*!*
-// error, no such function in Rabbit
+// помилка, такої функції в Rabbit немає
alert ( Rabbit.getOwnPropertyNames({a: 1, b: 2})); // Error
*/!*
```
-So `Rabbit` doesn't provide access to static methods of `Object` in that case.
+Тому `Rabbit` не надає доступу до статичних методів `Object` у цьому випадку.
-By the way, `Function.prototype` has "generic" function methods, like `call`, `bind` etc. They are ultimately available in both cases, because for the built-in `Object` constructor, `Object.__proto__ === Function.prototype`.
+До речі, `Function.prototype` має "загальні" методи функції, такі як `call`, `bind` тощо. Вони в кінцевому підсумку доступні в обох випадках, тому що для вбудованого конструктора `Object`, `Object.__proto__ === Function.prototype`.
-Here's the picture:
+Приклад на картинці:

-So, to put it short, there are two differences:
+Коротко кажучи, є дві відмінності:
| class Rabbit | class Rabbit extends Object |
|--------------|------------------------------|
-| -- | needs to call `super()` in constructor |
+| -- | необхідно викликати `super()` в конструкторі |
| `Rabbit.__proto__ === Function.prototype` | `Rabbit.__proto__ === Object` |
diff --git a/1-js/09-classes/03-static-properties-methods/3-class-extend-object/task.md b/1-js/09-classes/03-static-properties-methods/3-class-extend-object/task.md
index 1d0f98a74..e777f7dde 100644
--- a/1-js/09-classes/03-static-properties-methods/3-class-extend-object/task.md
+++ b/1-js/09-classes/03-static-properties-methods/3-class-extend-object/task.md
@@ -2,11 +2,11 @@ importance: 3
---
-# Class extends Object?
+# Клас розширює об’єкт?
-As we know, all objects normally inherit from `Object.prototype` and get access to "generic" object methods like `hasOwnProperty` etc.
+Як ми знаємо, всі об’єкти зазвичай успадковуються від `Object.prototype` й отримують доступ до «загальних» методів об’єкта, наприклад `hasOwnProperty` тощо.
-For instance:
+Наприклад:
```js run
class Rabbit {
@@ -18,16 +18,16 @@ class Rabbit {
let rabbit = new Rabbit("Rab");
*!*
-// hasOwnProperty method is from Object.prototype
+// метод hasOwnProperty від Object.prototype
alert( rabbit.hasOwnProperty('name') ); // true
*/!*
```
-But if we spell it out explicitly like `"class Rabbit extends Object"`, then the result would be different from a simple `"class Rabbit"`?
+Але що як ми пропишемо явно `"class Rabbit extends Object"` - тоді результат буде відрізнятися від звичайного `"class Rabbit"`?
-What's the difference?
+Яка різниця?
-Here's an example of such code (it doesn't work -- why? fix it?):
+Ось приклад такого коду (він не працює - чому? виправте його):
```js
class Rabbit extends Object {
diff --git a/1-js/09-classes/03-static-properties-methods/animal-rabbit-static.svg b/1-js/09-classes/03-static-properties-methods/animal-rabbit-static.svg
index 18093d7cf..76e4f4b75 100644
--- a/1-js/09-classes/03-static-properties-methods/animal-rabbit-static.svg
+++ b/1-js/09-classes/03-static-properties-methods/animal-rabbit-static.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/1-js/09-classes/03-static-properties-methods/article.md b/1-js/09-classes/03-static-properties-methods/article.md
index c75ec257f..8f0620ca7 100644
--- a/1-js/09-classes/03-static-properties-methods/article.md
+++ b/1-js/09-classes/03-static-properties-methods/article.md
@@ -1,9 +1,9 @@
-# Static properties and methods
+# Статичні властивості та методи
-We can also assign a method to the class function itself, not to its `"prototype"`. Such methods are called *static*.
+Ми також можемо присвоїти метод самій функції класу, а не її `"prototype"`. Такі методи називаються *статичними*.
-In a class, they are prepended by `static` keyword, like this:
+У класі перед ними стоїть ключове слово `static`, наприклад:
```js run
class User {
@@ -17,7 +17,7 @@ class User {
User.staticMethod(); // true
```
-That actually does the same as assigning it as a property directly:
+Фактично це те ж саме, що й безпосередньо присвоїти метод як властивість функції:
```js run
class User { }
@@ -29,11 +29,11 @@ User.staticMethod = function() {
User.staticMethod(); // true
```
-The value of `this` in `User.staticMethod()` call is the class constructor `User` itself (the "object before dot" rule).
+Значенням `this` при виклику `User.staticMethod()` є сам конструктор класу `User` (правило «об’єкт перед крапкою»).
-Usually, static methods are used to implement functions that belong to the class, but not to any particular object of it.
+Зазвичай статичні методи використовуються для реалізації функцій, які належать до класу, але не до будь-якого окремого його об’єкта.
-For instance, we have `Article` objects and need a function to compare them. A natural solution would be to add `Article.compare` method, like this:
+Наприклад, у нас є об’єкти статей `Article` і необхідна функція для їх порівняння. Очевидне рішення - додати метод `Article.compare`, наприклад:
```js run
class Article {
@@ -49,7 +49,7 @@ class Article {
*/!*
}
-// usage
+// використання
let articles = [
new Article("HTML", new Date(2019, 1, 1)),
new Article("CSS", new Date(2019, 0, 1)),
@@ -63,17 +63,17 @@ articles.sort(Article.compare);
alert( articles[0].title ); // CSS
```
-Here `Article.compare` stands "above" articles, as a means to compare them. It's not a method of an article, but rather of the whole class.
+Тут `Article.compare` стоїть «над» статтями, як засіб їх порівняння. Це не метод статті, а скоріше всього класу.
-Another example would be a so-called "factory" method. Imagine, we need few ways to create an article:
+Іншим прикладом може бути так званий «фабричний» метод. Уявіть собі, нам потрібно кілька способів, щоб створити статтю:
-1. Create by given parameters (`title`, `date` etc).
-2. Create an empty article with today's date.
-3. ...or else somehow.
+1. Створити за заданими параметрами (`title`, `date` тощо).
+2. Створити порожню статтю з сьогоднішньою датою.
+3. ...або якось інакше.
-The first way can be implemented by the constructor. And for the second one we can make a static method of the class.
+Перший спосіб може бути реалізований через конструктор. А для другого ми можемо використати статичний метод класу.
-Like `Article.createTodays()` here:
+Такий як `Article.createTodays()` тут:
```js run
class Article {
@@ -84,56 +84,56 @@ class Article {
*!*
static createTodays() {
- // remember, this = Article
- return new this("Today's digest", new Date());
+ // пам’ятайте, this = Article
+ return new this("Сьогоднішній дайджест", new Date());
}
*/!*
}
let article = Article.createTodays();
-alert( article.title ); // Today's digest
+alert( article.title ); // Сьогоднішній дайджест
```
-Now every time we need to create a today's digest, we can call `Article.createTodays()`. Once again, that's not a method of an article, but a method of the whole class.
+Тепер щоразу, коли нам потрібно створити сьогоднішній дайджест, ми можемо викликати `Article.createToday()`. Знову ж таки, це не метод конкретної статті, а метод цілого класу.
-Static methods are also used in database-related classes to search/save/remove entries from the database, like this:
+Статичні методи також використовуються в класах, що пов’язані з базою даних, для пошуку/збереження/видалення записів із бази даних, наприклад:
```js
-// assuming Article is a special class for managing articles
-// static method to remove the article:
+// припустимо, що Article - це спеціальний клас для керування статтями
+// статичний метод видалення статті:
Article.remove({id: 12345});
```
-## Static properties
+## Статичні властивості
[recent browser=Chrome]
-Static properties are also possible, they look like regular class properties, but prepended by `static`:
+Статичні властивості також можливі, вони виглядають як звичайні властивості класу, але до них додається `static`:
```js run
class Article {
- static publisher = "Ilya Kantor";
+ static publisher = "Ілля Кантор";
}
-alert( Article.publisher ); // Ilya Kantor
+alert( Article.publisher ); // Ілля Кантор
```
-That is the same as a direct assignment to `Article`:
+Це те саме, що й пряме присвоєння `Article`:
```js
-Article.publisher = "Ilya Kantor";
+Article.publisher = "Ілля Кантор";
```
-## Inheritance of static properties and methods [#statics-and-inheritance]
+## Спадкування статичних властивостей і методів [#statics-and-inheritance]
-Static properties and methods are inherited.
+Статичні властивості та методи наслідуються.
-For instance, `Animal.compare` and `Animal.planet` in the code below are inherited and accessible as `Rabbit.compare` and `Rabbit.planet`:
+Наприклад, `Animal.compare` та `Animal.planet` у коді нижче успадковуються та доступні як `Rabbit.compare` та `Rabbit.planet`:
```js run
class Animal {
- static planet = "Earth";
+ static planet = "Земля";
constructor(name, speed) {
this.speed = speed;
@@ -142,7 +142,7 @@ class Animal {
run(speed = 0) {
this.speed += speed;
- alert(`${this.name} runs with speed ${this.speed}.`);
+ alert(`${this.name} біжить зі швидкістю ${this.speed}.`);
}
*!*
@@ -156,61 +156,61 @@ class Animal {
// Inherit from Animal
class Rabbit extends Animal {
hide() {
- alert(`${this.name} hides!`);
+ alert(`${this.name} ховається!`);
}
}
let rabbits = [
- new Rabbit("White Rabbit", 10),
- new Rabbit("Black Rabbit", 5)
+ new Rabbit("Білий Кролик", 10),
+ new Rabbit("Чорний Кролик", 5)
];
*!*
rabbits.sort(Rabbit.compare);
*/!*
-rabbits[0].run(); // Black Rabbit runs with speed 5.
+rabbits[0].run(); // Чорний Кролик біжить зі швидкістю 5.
-alert(Rabbit.planet); // Earth
+alert(Rabbit.planet); // Земля
```
-Now when we call `Rabbit.compare`, the inherited `Animal.compare` will be called.
+Тепер, коли ми викликаємо `Rabbit.compare`, буде викликано успадкований `Animal.compare`.
-How does it work? Again, using prototypes. As you might have already guessed, `extends` gives `Rabbit` the `[[Prototype]]` reference to `Animal`.
+Як це працює? Знову ж таки, використовуючи прототипи. Як ви вже могли здогадатися, `extends` дає `Rabbit` посилання `[[Prototype]]` на `Animal`.

-So, `Rabbit extends Animal` creates two `[[Prototype]]` references:
+Отже, `Rabbit extends Animal` створює два посилання `[[Prototype]]`:
-1. `Rabbit` function prototypally inherits from `Animal` function.
-2. `Rabbit.prototype` prototypally inherits from `Animal.prototype`.
+1. Функція `Rabbit` прототипно успадковує від функції `Animal`.
+2. `Rabbit.prototype` прототипно успадковує від `Animal.prototype`.
-As a result, inheritance works both for regular and static methods.
+В результаті успадкування працює як для звичайних, так і для статичних методів.
-Here, let's check that by code:
+Перевірмо це кодом:
```js run
class Animal {}
class Rabbit extends Animal {}
-// for statics
+// для статичних
alert(Rabbit.__proto__ === Animal); // true
-// for regular methods
+// для звичайних методів
alert(Rabbit.prototype.__proto__ === Animal.prototype); // true
```
-## Summary
+## Підсумки
-Static methods are used for the functionality that belongs to the class "as a whole". It doesn't relate to a concrete class instance.
+Статичні методи використовуються для функціональності, що належить до класу «в цілому». Це не стосується конкретного екземпляра класу.
-For example, a method for comparison `Article.compare(article1, article2)` or a factory method `Article.createTodays()`.
+Наприклад, метод порівняння `Article.compare(article1, article2)` або фабричний метод `Article.createTodays()`.
-They are labeled by the word `static` in class declaration.
+В оголошенні класу вони позначені ключовим словом `static`.
-Static properties are used when we'd like to store class-level data, also not bound to an instance.
+Статичні властивості використовуються тоді, коли ми хочемо зберігати дані на рівні класу, а не якогось одного екземпляра.
-The syntax is:
+Синтаксис:
```js
class MyClass {
@@ -222,13 +222,13 @@ class MyClass {
}
```
-Technically, static declaration is the same as assigning to the class itself:
+Технічно, статичне оголошення – це те ж саме, що й присвоєння класу:
```js
MyClass.property = ...
MyClass.method = ...
```
-Static properties and methods are inherited.
+Статичні властивості та методи успадковуються.
-For `class B extends A` the prototype of the class `B` itself points to `A`: `B.[[Prototype]] = A`. So if a field is not found in `B`, the search continues in `A`.
+Для `class B extends A`, прототип класу `B` вказує на `A`: `B.[[Prototype]] = A`. Тож якщо поле не знайдено в `B`, пошук продовжується в `A`.