chore(i18n,curriculum): processed translations (#42581)
This commit is contained in:
@@ -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();
|
||||
|
@@ -36,7 +36,7 @@ Bird.prototype.eat = function() {
|
||||
};
|
||||
```
|
||||
|
||||
如果你有一個實例:`let duck = new Bird();`,然後你調用了 `duck.eat()`,以下就是 JavaScript 在 `duck’s` 的 `prototype` 鏈上尋找方法的過程:
|
||||
如果你有一個實例:`let duck = new Bird();`,然後你調用了 `duck.eat()`,以下就是 JavaScript 在 `duck` 的 `prototype` 鏈上尋找方法的過程:
|
||||
|
||||
1. `duck` => `eat()` 是定義在這裏嗎? 不是。
|
||||
2. `Bird` => `eat()` 是定義在這裏嗎? => 是的。 執行它並停止往上搜索。
|
||||
|
@@ -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;
|
||||
|
@@ -12,7 +12,7 @@ dashedName: use-prototype-properties-to-reduce-duplicate-code
|
||||
|
||||
當只有兩個實例時可能並不是什麼問題,但想象一下如果有數百萬個實例。 這將會產生許許多多重複的變量。
|
||||
|
||||
這裏有一個更好的方法可以解決上述問題,那就是使用 `Bird’s` 的 `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);
|
||||
|
@@ -16,7 +16,7 @@ dashedName: create-a-controlled-form
|
||||
|
||||
我們增加了一個提交表單的按鈕。 可以看到它的 `type` 被設置爲 `submit`,表明它是控制表單提交的按鈕。 在 `form` 中添加 `input` 元素,並像上個挑戰一樣設置其 `value` 和 `onChange()` 屬性。 然後,應該完成 `handleSubmit` 方法,以便將組件 state 屬性 `submit` 設置爲本地 `state` 下的當前輸入值。
|
||||
|
||||
**注意:** 還必須在提交處理程序中調用 `event.preventDefault()`,以防止默認的表單提交行爲刷新網頁。
|
||||
**注意:** 還必須在提交處理程序中調用 `event.preventDefault()`,以防止將會刷新網頁的默認的表單提交行爲。 爲了便於學員操作,默認行爲在這裏被禁用,以防止重置挑戰的代碼。
|
||||
|
||||
最後,在 `form` 元素之後創建一個 `h1` 標籤,該標籤從組件的 `state` 渲染 `submit` 的值。 然後,可以在表單中鍵入任何內容,然後單擊按鈕(或按 enter 鍵),輸入會渲染到頁面上。
|
||||
|
||||
@@ -98,7 +98,26 @@ assert(
|
||||
})();
|
||||
```
|
||||
|
||||
`h1` 標題應該從組件的 state 渲染 `submit` 字段的值。
|
||||
`handleSubmit` 應該調用 `event.preventDefault`。
|
||||
|
||||
```js
|
||||
const handleSubmit = MyForm.prototype.handleSubmit.toString();
|
||||
const allMatches = handleSubmit.match(/\bevent\.preventDefault\(\s*?\)/g) ?? [];
|
||||
const blockCommented = handleSubmit.match(
|
||||
/\/\*.*?\bevent\.preventDefault\(\s*?\).*?\*\//gs
|
||||
);
|
||||
const lineCommented = handleSubmit.match(
|
||||
/\/\/.*?\bevent\.preventDefault\(\s*?\)/g
|
||||
);
|
||||
const commentedMatches = [...(blockCommented ?? []), ...(lineCommented ?? [])];
|
||||
|
||||
assert(
|
||||
// At least one event.preventDefault() call exists and is not commented out
|
||||
allMatches.length > commentedMatches.length
|
||||
);
|
||||
```
|
||||
|
||||
`h1` 標頭應該從組件的 state 渲染 `submit` 字段的值。
|
||||
|
||||
```js
|
||||
(() => {
|
||||
|
@@ -18,8 +18,7 @@ dashedName: personal-library
|
||||
|
||||
# --instructions--
|
||||
|
||||
1. 將的 MongoDB 連接字符串添加到 `.env` 中(沒有引號),`DB`
|
||||
示例: `DB=mongodb://admin:pass@1234.mlab.com:1234/fccpersonallib`
|
||||
1. 將你的 MongoDB 連接字符串添加到 `.env` 中,作爲 `DB` 示例:`DB=mongodb://admin:pass@1234.mlab.com:1234/fccpersonallib`
|
||||
2. 在 `.env` 文件中設置 `NODE_ENV` 爲 `test`中,沒有引號
|
||||
3. 需要在 `routes/api.js` 中創建所有路由
|
||||
4. 在 `tests/2_functional-tests.js` 中創建所有的功能測試
|
||||
@@ -66,7 +65,7 @@ async (getUserInput) => {
|
||||
let a = $.post(url, { title: 'Faux Book A' });
|
||||
let b = $.post(url, { title: 'Faux Book B' });
|
||||
let c = $.post(url, { title: 'Faux Book C' });
|
||||
Promise.all([a, b, c]).then(async () => {
|
||||
await Promise.all([a, b, c]).then(async () => {
|
||||
let data = await $.get(url);
|
||||
assert.isArray(data);
|
||||
assert.isAtLeast(data.length, 3);
|
||||
@@ -214,8 +213,8 @@ async (getUserInput) => {
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
||||
|
Reference in New Issue
Block a user