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

# runtime

[JS](/web/js.md) ⟩ [concepts](/web/js/concept.md) ⟩ runtime

{% hint style="success" %}
the <mark style="color:orange;">**period**</mark> when a program is <mark style="color:yellow;">**running**</mark> (generally after [compile-time](/web/js/compile/compile-time.md)).
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
[scope](/web/js/scope.md)s&#x20;

* <mark style="color:yellow;">**determined**</mark> at [compile-time](/web/js/compile/compile-time.md).&#x20;
* <mark style="color:red;">**but**</mark> <mark style="color:yellow;">**created**</mark> at <mark style="color:purple;">**runtime**</mark> (each time a [scope](/web/js/scope.md) needs to run).
* [identifier](/web/js/grammar/token/id.md)s are <mark style="color:yellow;">**registered**</mark> to <mark style="color:yellow;">**respective**</mark> [scope](/web/js/scope.md) during [compile-time](/web/js/compile/compile-time.md).
* <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 <mark style="color:purple;">**runtime**</mark>. \
  ( 👉 [modify current scope at runtime❗️](/web/js/concept/env/js-engine/mode/sloppy-mode/modify-current-scope-at-runtime.md):exclamation:)
  {% endhint %}

{% hint style="warning" %}
[this](/web/js/concept/execution-context/this.md)&#x20;

* is <mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**fixed**</mark> in a [method](/web/js/val/obj/method.md).&#x20;
* <mark style="color:yellow;">**does**</mark>**&#x20;**<mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**necessarily refer**</mark> to the [object](/web/js/val/obj.md) containing the [method](/web/js/val/obj/method.md).
* is <mark style="color:yellow;">**passed**</mark> (at <mark style="color:purple;">**runtime**</mark>) by the <mark style="color:yellow;">**function call**</mark>.  👉 [method binding](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#method_binding).
  {% 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="🔴 主題" %}

* [dynamically typed](/web/js/val/type/term/dynamic.md) - the [type](/web/js/val/type.md) of a [value](/web/js/val.md) can be changed at <mark style="color:purple;">**runtime**</mark>.
* [dynamic binding](/web/js/grammar/token/id/dynamic-binding.md)\
  (the [value](/web/js/val.md) of an [identifier](/web/js/grammar/token/id.md) is <mark style="color:red;">**not determined**</mark> until <mark style="color:purple;">**runtime**</mark>)
  {% endtab %}

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

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

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

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