DEV Community

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

Posted on

3 1

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 😊

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay