# array-like

[JS](../../..) ⟩ [object](../../obj) ⟩ [built-in](..) ⟩ [Array]() ⟩ array-like

{% hint style="success" %}
objects that have <mark style="color:yellow;">**indexes**</mark> and <mark style="color:yellow;">**length**</mark>.
{% endhint %}

{% tabs %}
{% tab title="🔴 主題" %}
* <mark style="color:purple;">**array-likes**</mark>：
  * touchEvent.[touches](../../../../browser/event/type/touch/.touches) ([TouchList](https://developer.mozilla.org/en-US/docs/Web/API/TouchList))
  * [the "arguments" object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments)
  * [str](../../prim/str "mention")
{% endtab %}

{% tab title="👥 相關" %}
* **array-like** and [iterable](../../../iteration/iterable "mention") are <mark style="color:yellow;">**different**</mark> things.
{% endtab %}

{% tab title="💈範例" %}
```javascript
let arrayLike = { 
  0: "Hello",    // has indexes
  1: "World",
  length: 2,     // has length
}
```

:floppy\_disk: replit：[string is array-like](https://replit.com/@pegasusroe/string-is-array-like#index.js)

```javascript
// ⭐️ string is array-like
const str = 'abc'; 
str.length,       // 3   (string has length)
str[0],           // 'a' (string has numeric indexes)
```
{% endtab %}

{% tab title="📗 參考" %}
* [ ] JS.info ⟩ [iterables](https://javascript.info/iterable)
{% endtab %}

{% tab title="📘 手冊" %}
* [Array.from()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) - convert [iterable](../../../iteration/iterable "mention")/[array-like](array-like "mention") to [](<> "mention").
{% endtab %}
{% endtabs %}
