# escape sequence

[JS](../../..) ⟩ [value](../..) ⟩ [primitive](..) ⟩ [String]() ⟩ escape sequence

{% hint style="success" %}
```javascript
'\x4A'       // 'J'     ('\xXX')
'\u222B'     // '∫'     ('\uXXXX')
'\u{1F639}'  // '😹'    ('\u{0 ~ 10FFFF}'}
```
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
<table><thead><tr><th width="349">escape sequence</th><th>code points</th></tr></thead><tbody><tr><td><p><mark style="color:yellow;"><code>\xXX</code></mark> …</p><p>(<code>XX</code> = <code>00</code>~<code>FF</code>, <mark style="color:yellow;"><strong>2 hex digits</strong></mark>)</p></td><td><p>(<mark style="color:yellow;"><strong>Basic Latin</strong></mark> and Latin-1 Supplement)</p><p>(= <mark style="color:yellow;"><strong>ISO-8859-1</strong></mark>)</p><p><code>U+00</code><mark style="color:orange;"><strong><code>00</code></strong></mark> ~ <code>U+00</code><mark style="color:orange;"><strong><code>FF</code></strong></mark> </p></td></tr><tr><td><p><mark style="color:yellow;"><code>\uXXXX</code></mark></p><p>(<code>XXXX</code>= <code>0000 ~ FFFF</code>, <mark style="color:yellow;"><strong>4 hex digits</strong></mark>)</p></td><td><p>(<a href="unicode/code-plane"><strong>Basic Multilingual Plane</strong></a>)</p><p><code>U+</code><mark style="color:orange;"><strong><code>0000</code></strong></mark> ~ <code>U+</code><mark style="color:orange;"><strong><code>FFFF</code></strong></mark> </p></td></tr><tr><td><p><mark style="color:yellow;"><code>\u{X}</code></mark>…<mark style="color:yellow;"><code>\u{XXXXXX}</code></mark></p><p>(<code>X</code>…<code>XXXXXX</code>, <mark style="color:yellow;"><strong>1~6 hex digits</strong></mark>)</p></td><td><p>(the <mark style="color:yellow;"><strong>entirety</strong></mark> of <a href="unicode"><strong>Unicode</strong></a>)</p><p><code>U+000</code><mark style="color:orange;"><strong><code>0</code></strong></mark> ~ <code>U+</code><mark style="color:orange;"><strong><code>10FFFF</code></strong></mark> </p></td></tr></tbody></table>
{% endtab %}

{% tab title="👥 相關" %}
* [code-point](unicode/code-point "mention")(s) are used in <mark style="color:purple;">**escape sequences**</mark>.
{% endtab %}

{% tab title="💈範例" %}
* replit ⟩ [escape sequence](https://replit.com/@pegasusroe/escape-sequence#index.js)

```javascript
// ⭐ Basic Latin
// '\xXX': XX = 00 ~ FF (0 ~ 255, 2^8 code points)
'\x4A',       // 'J'
'\x7A',       // 'z'

// ⭐ BMP (Baisc Multilingual Plane / Plane 0)
// '\uXXXX': XXXX = 0000 ~ FFFF (0 ~ 65535, 2^16 code points)
'\u222B',     // '∫'

// ⭐ entire Unicode (Plane 0 ~ 16)
// '\u{X}' ~ '\u{XXXXXX}': 0 ~ 10FFFF (17 * 2^16 = 1,114,112 code points)
'\u{7A}',     // 'z'
'\u{121}',    // 'ġ'
'\u{1F639}',  // '😹'
```

* other examples：[octal escape sequence](https://replit.com/@pegasusroe/octal-escape-sequences)
{% endtab %}

{% tab title="📘 手冊" %}
* [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) ⟩ [escape sequences](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#escape_sequences)&#x20;
* [Grammar and types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types) ⟩ [Using special characters in strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#using_special_characters_in_strings)&#x20;
{% endtab %}
{% endtabs %}
