chore(i18n,curriculum): processed translations (#42581)

This commit is contained in:
camperbot
2021-06-21 19:13:43 +05:30
committed by GitHub
parent d1ac6d7a3a
commit 4aa6c6a00b
19 changed files with 119 additions and 81 deletions

View File

@ -17,7 +17,7 @@ Animal.prototype.eat = function() {
};
```
在這一節以及下一節挑戰中我們將學習如何在 `Bird``Dog` 中重用 `Animal's` 中的方法,而無需重新定義它們。 這裏我們會用到構造函數的繼承特性。 這一節挑戰中我們學習第一步:創建一個超類 `supertype`(或者叫父類)的實例。 你已經學會了一種創建 `Animal` 實例的方法,即使用 `new` 操作符:
在這一節以及下一節挑戰中我們將學習如何在 `Bird``Dog` 中重用 `Animal` 中的方法,而無需重新定義它們。 這裏我們會用到構造函數的繼承特性。 這一節挑戰中我們學習第一步:創建一個超類 `supertype`(或者叫父類)的實例。 你已經學會了一種創建 `Animal` 實例的方法,即使用 `new` 操作符:
```js
let animal = new Animal();
@ -29,7 +29,7 @@ let animal = new Animal();
let animal = Object.create(Animal.prototype);
```
`Object.create(obj)` 創建了一個新對象,並指定了 `obj` 作爲新對象的 `prototype`。 回憶一下,我們之前說過 `prototype` 就像是創建對象的“配方”。 如果我們把 `animal``prototype` 設置爲與 `Animal's` 構造函數的 `prototype` 一樣,那麼就相當於讓 `animal` 這個實例的配方`Animal` 其他實例的配方一樣了。
`Object.create(obj)` 創建了一個新對象,並指定了 `obj` 作爲新對象的 `prototype`。 回憶一下,我們之前說過 `prototype` 就像是創建對象的“配方”。 如果我們把 `animal``prototype` 設置爲與 `Animal` 構造函數的 `prototype` 一樣,那麼就相當於讓 `animal` 這個實例具有`Animal` 其他實例相同的“配方”了。
```js
animal.eat();

View File

@ -36,7 +36,7 @@ Bird.prototype.eat = function() {
};
```
如果你有一個實例:`let duck = new Bird();`,然後你調用了 `duck.eat()`,以下就是 JavaScript 在 `ducks``prototype` 鏈上尋找方法的過程:
如果你有一個實例:`let duck = new Bird();`,然後你調用了 `duck.eat()`,以下就是 JavaScript 在 `duck``prototype` 鏈上尋找方法的過程:
1. `duck` => `eat()` 是定義在這裏嗎? 不是。
2. `Bird` => `eat()` 是定義在這裏嗎? => 是的。 執行它並停止往上搜索。

View File

@ -19,7 +19,7 @@ let duck = new Bird();
duck.constructor
```
但是 `duck` 和其他所有 `Bird` 的實例都應該表明它們是由 `Bird` 創建的,而不是由 `Animal` 創建的。 爲此,你可以手動 `Bird's` constructor 屬性設置爲 `Bird` 對象:
但是 `duck` 和其他所有 `Bird` 的實例都應該表明它們是由 `Bird` 創建的,而不是由 `Animal` 創建的。 爲此,你可以手動 `Bird`構造函數屬性設置爲 `Bird` 對象:
```js
Bird.prototype.constructor = Bird;

View File

@ -12,7 +12,7 @@ dashedName: use-prototype-properties-to-reduce-duplicate-code
當只有兩個實例時可能並不是什麼問題,但想象一下如果有數百萬個實例。 這將會產生許許多多重複的變量。
這裏有一個更好的方法可以解決上述問題,那就是使用 `Birds``prototype``prototype` 是一個可以在所有 `Bird` 實例之間共享的對象。 以下是一個在 `Bird prototype` 中添加 `numLegs` 屬性的示例:
更好的方法是使用 `Bird``prototype``prototype` 是一個可以在所有 `Bird` 實例之間共享的對象。 以下是一個在 `Bird prototype` 中添加 `numLegs` 屬性的示例:
```js
Bird.prototype.numLegs = 2;
@ -45,7 +45,7 @@ assert(beagle.numLegs !== undefined);
assert(typeof beagle.numLegs === 'number');
```
`numLegs` 應該是一個 `prototype` 屬性而不是一個 `own` 屬性。
`numLegs` 應該是一個 `prototype` 屬性而不是一個自身屬性。
```js
assert(beagle.hasOwnProperty('numLegs') === false);