> 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/tips/fill-2d-array.md).

# fill 2D array

{% tabs %}
{% tab title="JS" %}

```javascript
// matrix (2D array) filled with 0
Array(3)                          // [ , , ]
  .fill()      
  .map( _ => Array(3).fill(0) );
```

{% endtab %}

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

* [Create 2d array in javascript filled with 0](https://pretagteam.com/question/create-2d-array-in-javascript-filled-with-0)
  {% endtab %}

{% tab title="💾 程式" %}

* replit - [SpiralMatrix 1.2](https://replit.com/@pegasusroe/SpiralMatrix-12#main.js)
  {% endtab %}
  {% endtabs %}
