# parameter vs. argument

[JS](https://lochiwei.gitbook.io/web/js) ⟩ [object](https://lochiwei.gitbook.io/web/js/val/obj) ⟩ [function](https://lochiwei.gitbook.io/web/js/val/func) ⟩ [parameter](https://lochiwei.gitbook.io/web/js/val/func/param) ⟩ argument vs. parameter

{% hint style="success" %}

* [param](https://lochiwei.gitbook.io/web/js/val/func/param "mention")(s)&#x20;
  * live in <mark style="color:yellow;">**function's definition**</mark> ([compile-time](https://lochiwei.gitbook.io/web/js/compile/compile-time "mention"))
  * <mark style="color:yellow;">**named**</mark> [variable](https://lochiwei.gitbook.io/web/js/variable "mention") <mark style="color:yellow;">**declared**</mark> in the [](https://lochiwei.gitbook.io/web/js/val/func "mention").
* [argument](https://lochiwei.gitbook.io/web/js/val/func/argument "mention")(s)&#x20;
  * live in <mark style="color:yellow;">**call sites**</mark> ( [runtime](https://lochiwei.gitbook.io/web/js/compile/runtime "mention"), may be <mark style="color:red;">**different**</mark> on each call)
  * a [..](https://lochiwei.gitbook.io/web/js/val "mention") for the <mark style="color:yellow;">**corresponding parameter**</mark>.

```javascript
// ⭐️ function's definition (compile-time)
function foo( param1, param2, ... ) { ... }
//           ╰─── parameters ────╯

// ⭐️ values passed into function when called (run-time)
foo( 1, 'hello', false );
//  ╰─── arguments ───╯
```

{% endhint %}

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

* [param](https://lochiwei.gitbook.io/web/js/val/func/param "mention")
* [argument](https://lochiwei.gitbook.io/web/js/val/func/argument "mention")
  {% endtab %}

{% tab title="📘 手冊" %}

* [x] [Argument](https://developer.mozilla.org/en-US/docs/Glossary/Argument)
* [x] [Parameter](https://developer.mozilla.org/en-US/docs/Glossary/Parameter)
* [ ] [the "arguments" object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments) - an [array-like](https://lochiwei.gitbook.io/web/js/val/builtin/arr/array-like "mention").
  {% endtab %}
  {% endtabs %}
