# nested destructuring

[JS](../../../..) ⟩ [operator](../..) ⟩ [assignment](..) ⟩ [destructuring]() ⟩ nested

{% tabs %}
{% tab title="💾 程式" %}
💾 程式：[replit](https://replit.com/@pegasusroe/JS-nested-destructuring#index.js)

```javascript
let opts = {
    size : {width: 100, height: 200},    // object in object
    items: ["Cake", "Donut"],            // array in object
    extra: true
};

// ⭐ nested destructuring
let {
  size : {width, height},
  items: [a, b],
  title = "Menu"                         // default value
} = opts;
// width=100, height=200, a="Cake", b="Donut", title="Menu"
```
{% endtab %}

{% tab title="📗 參考" %}
* [x] JS.info ⟩ [nested destructuring](https://javascript.info/destructuring-assignment#nested-destructuring)
* [ ] Ronald Chen ⟩ [Destructuring Nested Objects](https://medium.com/@pyrolistical/destructuring-nested-objects-9dabdd01a3b8)
* [ ] Jay Cruz ⟩ [How to Destructure Nested JavaScript Objects](https://dev.to/coderjay06/how-to-destructure-nested-javascript-objects-1dcl)
{% endtab %}

{% tab title="👥 相關" %}
* [arr](arr "mention")
* [obj](obj "mention")
{% endtab %}

{% tab title="⬇️ 應用" %}
* [maketable](../../../../../appendix/gas/app/member/maketable "mention")
{% endtab %}

{% tab title="🗣 討論" %}
* [ES6 deep nested object destructuring](https://stackoverflow.com/questions/40622385/es6-deep-nested-object-destructuring)
{% endtab %}
{% endtabs %}
