Skip to content

Commit 8f918ce

Browse files
committed
Translation zh-TW answer 97
1 parent 5f3814c commit 8f918ce

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

zh-TW/README_zh-TW.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,6 +3072,36 @@ console.log(member.name)
30723072
我們可以將class設置為等於其他class/函數建構函數。在這種情況下,我們將`Person`設置為`AnotherPerson`。這個建構函數的名字是`Sarah`,所以新的`Person`實例`member`上的name屬性是`Sarah`
30733073

30743074

3075+
</p>
3076+
</details>
3077+
3078+
---
3079+
###### 97. 將會輸出什麽內容?
3080+
3081+
```javascript
3082+
const info = {
3083+
[Symbol('a')]: 'b'
3084+
}
3085+
3086+
console.log(info)
3087+
console.log(Object.keys(info))
3088+
```
3089+
3090+
- A: `{Symbol('a'): 'b'}` and `["{Symbol('a')"]`
3091+
- B: `{}` and `[]`
3092+
- C: `{ a: "b" }` and `["a"]`
3093+
- D: `{Symbol('a'): 'b'}` and `[]`
3094+
3095+
<details><summary><b>答案</b></summary>
3096+
<p>
3097+
3098+
#### 答案: D
3099+
3100+
3101+
`Symbol`類型是不可枚舉的。 `Object.keys`函數回傳物件上的所有可枚舉的鍵屬性。 `Symbol`類型是不可見的,並返回一個空陣列。記錄整個物件時,所有屬性都是可見的,甚至是不可枚舉的屬性。
3102+
3103+
這是`Symbol`的眾多特性之一:除了表示完全唯一的值(防止物件意外名稱衝突,例如當使用2個想要向同一物件添加屬性的庫時),您還可以`隱藏`這種方式物件的屬性(儘管不完全。你仍然可以使用`Object.getOwnPropertySymbols()`函數存取`Symbol`
3104+
30753105
</p>
30763106
</details>
30773107

0 commit comments

Comments
 (0)