Skip to content

Commit

Permalink
Translation zh-TW answer 91
Browse files Browse the repository at this point in the history
  • Loading branch information
sexyoung committed Jul 2, 2021
1 parent d9ed0cf commit 3f2adf5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions zh-TW/README_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2870,4 +2870,30 @@ function Person() {
</p>
</details>

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

```javascript
let newList = [1, 2, 3].push(4)

console.log(newList.push(5))
```

- A: `[1, 2, 3, 4, 5]`
- B: `[1, 2, 3, 5]`
- C: `[1, 2, 3, 4]`
- D: `Error`

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

#### 答案: D

`.push`函數回傳陣列的長度,而不是陣列本身!通過將`newList`設置為`[1,2,3].push(4)`,實際上`newList`等於陣列的新長度:`4`

然後,嘗試在`newList`上使用`.push`函數。由於`newList`是數值`4`,拋出TypeError。

</p>
</details>

---

0 comments on commit 3f2adf5

Please sign in to comment.