---
description: a value passed into function as input.
---

# argument

[JS](../..) ⟩ [value](..) ⟩ [function]() ⟩ argument

{% hint style="success" %}
a [..](.. "mention") <mark style="color:yellow;">**passed into**</mark> a [](<> "mention"), [param](param "mention")(s) are <mark style="color:yellow;">**initialized**</mark> to these values.&#x20;
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="info" %}
:scales:[vs-arg](vs-arg "mention")
{% endhint %}

{% hint style="warning" %}
:exclamation:[arguments-are-passed-by-value](argument/arguments-are-passed-by-value "mention")
{% endhint %}
{% endtab %}

{% tab title="👥 相關" %}
* a [](<> "mention") passed into another function as <mark style="color:purple;">**argument**</mark> is called a [callback](kind/callback "mention").
* [**...iterable**](../../grammar/op/spread) <mark style="color:yellow;">**expands**</mark> an [**iterable**](../../iteration/iterable) in places where <mark style="color:purple;">**arguments**</mark> are expected.&#x20;
{% endtab %}

{% tab title="💈範例" %}
```javascript
// ⭐️ parameters:
//   • lie in function's definition (compile-time)
function foo( param1, param2, ... ) { ... }
//           ╰─── parameters ────╯

// ⭐️ arguments:
//   • values passed into function when called (run-time)
//   • parameters are initialized to these values.
//   • can be different on each call.
foo( 1, 'hello', false );
//  ╰─── arguments ───╯

foo( 2, 'world', false );
//  ╰─── arguments ───╯
```
{% endtab %}

{% tab title="📗 參考" %}
* [ ] [JavaScript Tutorial](https://www.javascripttutorial.net/) ⟩ [Understanding JavaScript Pass-By-Value](https://www.javascripttutorial.net/javascript-pass-by-value/)
{% 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](../builtin/arr/array-like "mention") object.
{% endtab %}

{% tab title="🗣 討論" %}
* [Where are arguments positioned in the lexical environment?](https://stackoverflow.com/questions/61208843/where-are-arguments-positioned-in-the-lexical-environment) ⭐️
{% endtab %}
{% endtabs %}
