Object Array length returns undefined in JavaScript
<p>I have an array as displayed below in the console.</p>

<pre><code>console.log(roles);

User {0: "AdminUser", 1: "AuthenticatedUser"}
</code></pre>

<p>Although it is an array I am unable to get the array length.</p>

<pre><code>console.log(roles.length);

undefined
</code></pre>

<p>But if access the array using index, I am able to get the value as shown below.</p>

<pre><code>console.log(roles[0]);

AdminUser
</code></pre>