> 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/array-like.md).

# array-like

[JS](/web/js.md) ⟩ [object](/web/js/val/obj.md) ⟩ [built-in](/web/js/val/builtin.md) ⟩ [Array](/web/js/val/builtin/arr.md) ⟩ 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](/web/browser/event/type/touch/.touches.md) ([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)
  * [String](/web/js/val/prim/str.md)
    {% endtab %}

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

* **array-like** and [iterable](/web/js/iteration/iterable.md) 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](/web/js/iteration/iterable.md)/[array-like](/web/js/val/builtin/arr/array-like.md) to [Array](/web/js/val/builtin/arr.md).
  {% endtab %}
  {% endtabs %}
