# creating arrays

[JS](../../..) ⟩ [object](../../obj) ⟩ [built-in](..) ⟩ [Array]() ⟩ 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:[arr](create/arr "mention")
{% endtab %}

{% tab title="👥 相關" %}
* <mark style="color:purple;">**Array.of()**</mark> / <mark style="color:purple;">**Array.from()**</mark> are introduced in [es6](../../../feature/es6 "mention").
{% endtab %}

{% tab title="📗 參考" %}
* [javascript-the-definitive-guide](../../../../master/ref/javascript-the-definitive-guide "mention") > 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 %}
