From ed471958927c5d09a379e13a31b7e4ccd6550c94 Mon Sep 17 00:00:00 2001 From: s0nought <70777299+s0nought@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:57:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=20=D1=84=D1=80=D0=B0=D0=B7=20=D0=B2=208.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../01-prototype-inheritance/article.md | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/1-js/08-prototypes/01-prototype-inheritance/article.md b/1-js/08-prototypes/01-prototype-inheritance/article.md index 01f3584a07..cf96e2b883 100644 --- a/1-js/08-prototypes/01-prototype-inheritance/article.md +++ b/1-js/08-prototypes/01-prototype-inheritance/article.md @@ -71,7 +71,7 @@ let animal = { eats: true, *!* walk() { - alert("Animal walk"); + alert("Животное идёт"); } */!* }; @@ -83,7 +83,7 @@ let rabbit = { // walk взят из прототипа *!* -rabbit.walk(); // Animal walk +rabbit.walk(); // Животное идёт */!* ``` @@ -97,7 +97,7 @@ rabbit.walk(); // Animal walk let animal = { eats: true, walk() { - alert("Animal walk"); + alert("Животное идёт"); } }; @@ -116,7 +116,7 @@ let longEar = { }; // walk взят из цепочки прототипов -longEar.walk(); // Animal walk +longEar.walk(); // Животное идёт alert(longEar.jumps); // true (из rabbit) ``` @@ -165,11 +165,11 @@ let rabbit = { *!* rabbit.walk = function() { - alert("Rabbit! Bounce-bounce!"); + alert("Кролик! Прыг-скок!"); }; */!* -rabbit.walk(); // Rabbit! Bounce-bounce! +rabbit.walk(); // Кролик! Прыг-скок! ``` Теперь вызов `rabbit.walk()` находит метод непосредственно в объекте и выполняет его, не используя прототип: @@ -199,10 +199,14 @@ let admin = { isAdmin: true }; +*!* alert(admin.fullName); // John Smith (*) +*/!* // срабатывает сеттер! +*!* admin.fullName = "Alice Cooper"; // (**) +*/!* alert(admin.name); // Alice alert(admin.surname); // Cooper ``` @@ -230,7 +234,7 @@ alert(admin.surname); // Cooper let animal = { walk() { if (!this.isSleeping) { - alert(`I walk`); + alert('Я иду'); } }, sleep() { @@ -239,7 +243,7 @@ let animal = { }; let rabbit = { - name: "White Rabbit", + name: "Белый кролик", __proto__: animal }; @@ -276,12 +280,12 @@ let rabbit = { *!* // Object.keys возвращает только собственные ключи -alert(Object.keys(rabbit)); // jumps +alert( Object.keys(rabbit) ); // jumps */!* *!* // for..in проходит и по своим, и по унаследованным ключам -for(let prop in rabbit) alert(prop); // jumps, затем eats +for (let prop in rabbit) alert(prop); // jumps, затем eats */!* ``` @@ -299,13 +303,13 @@ let rabbit = { __proto__: animal }; -for(let prop in rabbit) { +for (let prop in rabbit) { let isOwn = rabbit.hasOwnProperty(prop); if (isOwn) { - alert(`Our: ${prop}`); // Our: jumps + alert(`Собственное: ${prop}`); // Собственное: jumps } else { - alert(`Inherited: ${prop}`); // Inherited: eats + alert(`Унаследованное: ${prop}`); // Унаследованное: eats } } ``` pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy