> 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/compile-time.md).

# compile-time

[JS](/web/js.md) ⟩ [concepts](/web/js/concept.md) ⟩ compile-time

{% hint style="success" %}
the <mark style="color:orange;">**period**</mark> when the <mark style="color:yellow;">**source code**</mark> (such as [C#](https://docs.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/),  [Java, C, Python](https://www.baeldung.com/cs/max-int-java-c-python)) is converted to the [machine code](https://www.baeldung.com/cs/how-compilers-work) (i.e. <mark style="color:yellow;">**binary code**</mark>).
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="success" %}
[scope](/web/js/scope.md)s are determined at <mark style="color:purple;">**compile-time**</mark>.&#x20;

* [identifier](/web/js/grammar/token/id.md)s are <mark style="color:yellow;">**registered**</mark> to respective [scope](/web/js/scope.md) during <mark style="color:purple;">**compile-time**</mark>.
* <mark style="color:red;">**but in**</mark> [sloppy mode](/web/js/concept/env/js-engine/mode/sloppy-mode.md), you can <mark style="color:red;">**cheat**</mark> it at [runtime](/web/js/compile/runtime.md). \
  ( 👉 [modify current scope at runtime❗️](/web/js/concept/env/js-engine/mode/sloppy-mode/modify-current-scope-at-runtime.md):exclamation:)
  {% endhint %}

{% hint style="info" %}
[parameter vs. argument](/web/js/val/func/vs-arg.md)

* [parameter](/web/js/val/func/param.md)(s) live in <mark style="color:yellow;">**function's definition**</mark> ([compile-time](/web/js/compile/compile-time.md))
* [argument](/web/js/val/func/argument.md)(s) live in <mark style="color:yellow;">**call sites**</mark> ([runtime](/web/js/compile/runtime.md), may be <mark style="color:red;">**different**</mark> <mark style="color:yellow;">**on each call**</mark>)
  {% endhint %}
  {% endtab %}

{% tab title="🔴 主題" %}

* [statically typed](/web/js/val/type/term/static.md) - the [type](/web/js/val/type.md) of a [value](/web/js/val.md) <mark style="color:red;">**can't be changed**</mark> at [runtime](/web/js/compile/runtime.md).
* [static binding](/web/js/grammar/token/id/static-binding.md)\
  (the [value](/web/js/val.md) of an [identifier](/web/js/grammar/token/id.md) is <mark style="color:green;">**predetermined**</mark> at [compile-time](/web/js/compile/compile-time.md))
* [compile-time error](/web/js/err/compile.md)
  {% endtab %}

{% tab title="👥 相關" %}

* [compilation](/web/js/compile.md) - how JS is compiled
* compare：[runtime](/web/js/compile/runtime.md)
* [scope](/web/js/scope.md)s are <mark style="color:yellow;">**determined**</mark> at <mark style="color:purple;">**compile time**</mark>.
  {% endtab %}

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

* [ ] Baeldung ⟩ [Runtime vs. Compile Time](https://www.baeldung.com/cs/runtime-vs-compile-time)
  {% endtab %}
  {% endtabs %}
