The following substitutions are made:
| Character | Replacement |
|---|---|
\ | \\ |
" | \\ |
' | \\ |
\r (carriage return) | \\r |
\n (line feed) | \\n |
| Characters from 0x00 to 0x1f | \\x## where ## is two hex digits |
| Characters from 0x80 to 0xffff | \\u#### where #### is four hex digits |
Also see the stringify Operator.