Skip to content

@technobuddha > library > Programming > Escaping

Function: unescapeJS()

ts
function unescapeJS(input: string): string;

Defined in: unescape-js.ts:32

Unescape a string encoded in Javascript style

Escape SequenceCharacterHex
\bBackspace0x08
\tTab0x09
\nNewline0x0a
\vVertical Tab0x0b
\fForm Feed0x0c
\rCarriage Return0x0d
\"Double Quote0x22
\'Single Quote0x27
\\Backslash0x5c
\n…n[^1]Octal Escape0x0000-0x01ff
\xnnHexadecimal Escape0x0000-0x00ff
\unnnnUnicode Escape0x00000-0x00ffff
\uCode Point Escape0x00000-0x10ffff

Parameters

ParameterTypeDescription
inputstringthe string to unescape

Returns

string

the string with escapes resolved

Example

typescript
unescapeJS('Hello\\nWorld'); // "Hello\nWorld"
unescapeJS('\\u20ac'); // "€"
unescapeJS('\\x48\\x65\\x6c\\x6c\\x6f'); // "Hello"
unescapeJS('\\u{1F600}'); // "😀"