> 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/val/func/param/rest-parameters.md).

# rest parameters

[JS](/web/js.md) ⟩ [object](/web/js/val/obj.md) ⟩ [function](/web/js/val/func.md) ⟩ [parameter](/web/js/val/func/param.md) ⟩ rest parameters

{% hint style="success" %}
🚧
{% endhint %}

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

* [rest parameters as object](/web/js/val/func/param/rest-parameters/rest.md)
  {% endtab %}

{% tab title="💈範例" %}
💾 程式：[replit](https://replit.com/join/kvserhbykg-lochiwei)

```javascript
const { log } = console;

function f({        // parameter destructuring
    hi = 0,         // default parameter
    
    ...opts         // rest params as an object ⭐️
    
} = {})             // default parameter
{
    log(hi);
    log(opts);
}

// test run
f();                        // 0, {}
f({ x: 1, y: 2, hi: 3 });   // 3, { x: 1, y: 2 }
```

{% endtab %}

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

* [destructuring assignment](/web/js/grammar/op/assign/destruct.md)
* [rest operator (...)](/web/js/grammar/op/rest-operator-....md)
  {% endtab %}

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

* [Rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters)
  {% endtab %}
  {% endtabs %}
