File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -2245,4 +2245,39 @@ console.log(/* 2 */); // JavaScript 也愛你 ❤️
2245
2245
</p >
2246
2246
</details >
2247
2247
2248
+ ---
2249
+
2250
+ ###### 72. 將會輸出什麽內容?
2251
+
2252
+ ``` javascript
2253
+ console .log (String .raw ` Hello\n world` );
2254
+ ```
2255
+
2256
+ - A: ` Hello world! `
2257
+ - B: ` Hello ` <br />  ;   ;   ; ` world `
2258
+ - C: ` Hello\nworld `
2259
+ - D: ` Hello\n ` <br />   ;   ;   ; ` world `
2260
+
2261
+ <details ><summary ><b >答案</b ></summary >
2262
+ <p >
2263
+
2264
+ #### 答案: C
2265
+
2266
+ ` String.raw ` 會回傳一個字串,其中轉義符(` /n ` , ` /v ` , ` /t ` 等)被忽略! 反斜線可能是一個問題,因為你可能會有這樣的結果。
2267
+
2268
+ ` const path = "C:\Documents\Projects\table.html" ` 。
2269
+
2270
+ 將會得到:
2271
+
2272
+ ` C:DocumentsProjects able.html `
2273
+
2274
+ 如果使用` String.raw ` ,它將直接忽略轉譯並輸出。
2275
+
2276
+ ` C:\Documents\Projects\table.html ` 。
2277
+
2278
+ 在這種情況下,字串會以 "Hello\nworld",被記錄下來。
2279
+
2280
+ </p >
2281
+ </details >
2282
+
2248
2283
---
You can’t perform that action at this time.
0 commit comments