Skip to content

Commit

Permalink
Translation zh-TW answer 96
Browse files Browse the repository at this point in the history
  • Loading branch information
sexyoung committed Jul 2, 2021
1 parent c4a98fa commit 5f3814c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions zh-TW/README_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,43 @@ console.log(nums(1, 2))

這意味著永遠不會到達`a + b`,因為函數在`return`關鍵字之後停止運行。如果沒有回傳值,就像這裡,函數回傳`undefined`。注意,在`if/else`語法之後沒有自動插入!

</p>
</details>

---
###### 96. 將會輸出什麽內容?

```javascript
class Person {
constructor() {
this.name = "Lydia"
}
}

Person = class AnotherPerson {
constructor() {
this.name = "Sarah"
}
}

const member = new Person()
console.log(member.name)
```

- A: `"Lydia"`
- B: `"Sarah"`
- C: `Error: cannot redeclare Person`
- D: `SyntaxError`

<details><summary><b>答案</b></summary>
<p>

#### 答案: B


我們可以將class設置為等於其他class/函數建構函數。在這種情況下,我們將`Person`設置為`AnotherPerson`。這個建構函數的名字是`Sarah`,所以新的`Person`實例`member`上的name屬性是`Sarah`


</p>
</details>

Expand Down

0 comments on commit 5f3814c

Please sign in to comment.