> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/compile/js-compiled.md).

# JS is compiled

JavaScript is a compiled language

[JS](/web/js.md) ⟩ [concepts](/web/js/concept.md) ⟩ [compiler](/web/js/compile.md) ⟩ JS is compiled

{% hint style="info" %}
JavaScript code is <mark style="color:yellow;">**compiled**</mark> first, and then <mark style="color:yellow;">**execute**</mark>.
{% endhint %}

{% tabs %}
{% tab title="💈範例" %}
{% hint style="danger" %}
⛔ <mark style="color:red;">**SyntaxError**</mark>: <mark style="color:yellow;">**unexpected token**</mark> "xxx"
{% endhint %}

* replit：[JS is a compiled language](https://replit.com/@pegasusroe/JS-is-a-compiled-language#index.js)

```javascript
var greeting = "Hello";
console.log(greeting);   // ⭐️ this line doesn't have a chance to run❗ 

greeting = ."Hi";        // ⭐️ error occurred in the "tokenizing" stage
//         ↑             //    of compilation❗
//         ↑
// ⛔ SyntaxError: unexpected token .
```

{% endtab %}

{% tab title="📗 參考" %}

* [ ] [YDKJS: Scope & Closures (v.2)](/web/master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2.md) ⟩ [Ch. 1: What's the Scope?](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch1.md#chapter-1-whats-the-scope)
  {% endtab %}
  {% endtabs %}
