File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -3336,4 +3336,43 @@ Promise.resolve(5)
3336
3336
3337
3337
</p >
3338
3338
</details >
3339
+ ---
3340
+
3341
+ ###### 105. 將會輸出什麽內容?
3342
+
3343
+ ``` javascript
3344
+ function compareMembers (person1 , person2 = person ) {
3345
+ if (person1 !== person2) {
3346
+ console .log (" Not the same!" )
3347
+ } else {
3348
+ console .log (" They are the same!" )
3349
+ }
3350
+ }
3351
+
3352
+ const person = { name: " Lydia" }
3353
+
3354
+ compareMembers (person)
3355
+ ```
3356
+
3357
+ - A: ` Not the same! `
3358
+ - B: ` They are the same! `
3359
+ - C: ` ReferenceError `
3360
+ - D: ` SyntaxError `
3361
+
3362
+ <details ><summary ><b >答案</b ></summary >
3363
+ <p >
3364
+
3365
+ #### 答案: B
3366
+
3367
+ 物件通過參考位址傳遞。當我們檢查物件的嚴格相等性(===)時,我們正在比較它們的參考位址。
3368
+
3369
+ 我們將“person2”的預設值設置為“person”物件,並將“person”對像作為“person1”的值傳遞。
3370
+
3371
+ 這意味著兩個值都引用內存中的同一位置,因此它們是相等的。
3372
+
3373
+ 運行“ else”語句中的代碼塊,並記錄` They are the same! ` 。
3374
+
3375
+ </p >
3376
+ </details >
3377
+
3339
3378
---
You can’t perform that action at this time.
0 commit comments