# arr.entries

[JS](../../../..) ⟩ [objects](../../../obj) ⟩ [Array](..) ⟩ [methods]() ⟩ 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](../ext/arr.rank "mention") - rank an array of objects.
{% endtab %}

{% tab title="👥 相關" %}
* [of](../../../../grammar/statement/loop/for/of "mention")
{% endtab %}
{% endtabs %}
