> 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/builtin/arr/create.md).

# creating arrays

[JS](/web/js.md) ⟩ [object](/web/js/val/obj.md) ⟩ [built-in](/web/js/val/builtin.md) ⟩ [Array](/web/js/val/builtin/arr.md) ⟩ creating arrays

{% hint style="success" %}
arrays can be created using：

```javascript
[1,2,3]          // array literal
[...iterable]    // spread operator

// Array() constructor
new Array()      // === []
new Array(3)     // === [,,,,] (compare with Array.of(3))
new Array(1,2,3) // === [1,2,3]

// Array.of() factory method (⭐️ ES6)
Array.of()       // === []
Array.of(3)      // === [3]
Array.of(1,2,3)  // === [1,2,3]

// Array.from() factory method (⭐️ ES6)
Array.from(iterable)    // === [...iterable]
Array.from(arrayLike)   // array-like -> array
Array.from(iterableOrArrayLike, mapFunc, thisArg)    // general form
```

{% endhint %}

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

* :1234:[array literal](/web/js/val/builtin/arr/create/arr.md)
  {% endtab %}

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

* <mark style="color:purple;">**Array.of()**</mark> / <mark style="color:purple;">**Array.from()**</mark> are introduced in [⭐️ ES6 (2015)](/web/js/feature/es6.md).
  {% endtab %}

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

* [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) > 7.1 Creating Arrays
  {% endtab %}

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

* [Array.from()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
  {% endtab %}
  {% endtabs %}
