DEV Community

Cover image for The Difference Between Arrays and Objects(simplest explaination).
Mahendra Bishnoi
Mahendra Bishnoi

Posted on

The Difference Between Arrays and Objects(simplest explaination).

In JavaScript, arrays use numbered indexes.

In JavaScript, objects use named indexes.

Arrays are a special kind of objects, with numbered indexes.

When to Use Arrays. When to use Objects.

  1. JavaScript does not support associative arrays.
  2. You should use objects when you want the element names to be strings (text).
  3. You should use arrays when you want the element names to be numbers.

Top comments (2)

Collapse
 
prakh_r profile image
Prakhar Yadav

sweet quick notes 🥂 We need more of these

Collapse
 
browncoder profile image
Mahendra Bishnoi

glad you liked it .. more are coming on important topics 😊