File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -3072,6 +3072,36 @@ console.log(member.name)
3072
3072
我們可以將class設置為等於其他class/函數建構函數。在這種情況下,我們將` Person ` 設置為` AnotherPerson ` 。這個建構函數的名字是` Sarah ` ,所以新的` Person ` 實例` member ` 上的name屬性是` Sarah ` 。
3073
3073
3074
3074
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
+
3075
3105
</p >
3076
3106
</details >
3077
3107
You can’t perform that action at this time.
0 commit comments