Skip to content

Commit

Permalink
Translation zh-TW answer 90
Browse files Browse the repository at this point in the history
  • Loading branch information
sexyoung committed Jul 2, 2021
1 parent 56e36d6 commit d9ed0cf
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 @@ -2834,3 +2834,40 @@ console.log(data)
</details>

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

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

const member = new Person("John")
console.log(typeof member)
```

- A: `"class"`
- B: `"function"`
- C: `"object"`
- D: `"string"`

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

#### 答案: C

class是建構函數的語法糖,如果用建構函數的方式來重寫`Person`class則會是:

```javascript
function Person() {
this.name = name
}
```

透過`new`來呼叫建構函數,將會產生建構函數`Person`的實例,對實例執行`typeof`關鍵字將返回`"object"`,上述情況輸出`"object"`

</p>
</details>

---

0 comments on commit d9ed0cf

Please sign in to comment.