Escape and unescape JavaScript string literals with proper handling of quotes, backslashes, and special characters for safe code generation and data handling in web applications.
Common escape sequences used in JavaScript string literals
| Character | Escape Sequence | Unicode | Description |
|---|---|---|---|
" | \" | \u0022 | Double quote |
' | \' | \u0027 | Single quote |
` | \` | \u0060 | Backtick |
\ | \\ | \u005C | Backslash |
newline | \n | \u000A | Line feed |
tab | \t | \u0009 | Horizontal tab |
carriage return | \r | \u000D | Carriage return |
vertical tab | \v | \u000B | Vertical tab |
backspace | \b | \u0008 | Backspace |
form feed | \f | \u000C | Form feed |
null | \0 | \u0000 | Null character |