Skip to content

Commit d931cde

Browse files
vxnshKsadanandpai
authored andcommitted
Init String Escape Sequence Concept
1 parent c08424a commit d931cde

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

web/src/pages/concepts/primitives.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,38 @@ Symbols are skipped by for…in
408408
409409
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
410410
- https://javascript.info/symbol
411+
412+
---
413+
414+
### 14. Demonstrate the usage of String Escape Sequences
415+
416+
- Specifies that the following character should be interpreted as a literal character
417+
418+
```js copy
419+
// 1. Newline and Tab
420+
const newlineTabExample = "Line 1\nLine 2\tTabbed";
421+
console.log(newlineTabExample);
422+
// Output:
423+
// Line 1
424+
// Line 2 Tabbed
425+
426+
// 2. Escaping Double Quotes
427+
const escapeDoubleQuoteExample = "He said, \"Hello, World!\"";
428+
console.log(escapeDoubleQuoteExample);
429+
// Output: He said, "Hello, World!"
430+
431+
// 3. Escaping Single Quotes
432+
const escapeSingleQuoteExample = 'It\'s a wonderful day!';
433+
console.log(escapeSingleQuoteExample);
434+
// Output: It's a wonderful day!
435+
436+
// 4. Unicode Smiley Face
437+
const unicodeSmileyExample = "Smile: \u263A";
438+
console.log(unicodeSmileyExample);
439+
// Output: Smile: ☺
440+
441+
// 5. File Path with Double Backslashes
442+
const filePathExample = "Path: C:\\\\Program Files\\\\MyApp";
443+
console.log(filePathExample);
444+
// Output: Path: C:\\Program Files\\MyApp
445+
```

0 commit comments

Comments
 (0)