> 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/method/arr.entries.md).

# arr.entries

[JS](/web/js.md) ⟩ [objects](/web/js/val/obj.md) ⟩ [Array](/web/js/val/builtin/arr.md) ⟩ [methods](/web/js/val/builtin/arr/method.md) ⟩ entries()

{% tabs %}
{% tab title="🧨 雷區" %}
{% hint style="danger" %}

* [Object.entries()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) - keys are <mark style="color:red;">**string**</mark>-based.
* [Array.prototype.entries()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries) - keys are <mark style="color:yellow;">**integer**</mark>-based.
  {% endhint %}

:floppy\_disk: replit: [arr.entries() vs Object.entries(arr)](https://replit.com/@pegasusroe/arrentries-vs-Objectentriesarr#index.js)

```javascript
const a = ['a', 'b', 'c'];
    
// ⭐️ keys are "integers"
Array.from(a.entries()),    // [ [ 0, 'a' ], [ 1, 'b' ], [ 2, 'c' ] ]

// ⭐️ keys are "strings"
Object.entries(a),          // [ [ '0', 'a' ], [ '1', 'b' ], [ '2', 'c' ] ]

for(const [i, value] of Object.entries(a)) {
    console.log(i + 1);     // 🧨 雷區：'01', '11', '21' ❗❗❗ 
}
```

{% endtab %}

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

* [Object.entries()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) - keys are <mark style="color:red;">**string**</mark>-based.
* [Array.prototype.entries()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries) - keys are <mark style="color:yellow;">**integer**</mark>-based.
  {% endtab %}

{% tab title="⬇️ 應用" %}

* [arr.rank()](/web/js/val/builtin/arr/ext/arr.rank.md) - rank an array of objects.
  {% endtab %}

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

* [for-of](/web/js/grammar/statement/loop/for/of.md)
  {% endtab %}
  {% endtabs %}
