Array vs Object in JavaScript — What's the Difference?

A JavaScript array is an ordered list of values indexed by number, optimized for sequential collections; a plain object is an unordered collection of key-val...

Published November 24, 2026

Arrays are ordered lists accessed by numeric index, ideal for sequences; objects are collections of named properties accessed by key, ideal for records. Arrays are actually special objects with a length and list methods.

The concept

Use arrays for ordered collections you loop over (map, filter). Use objects for entities with named fields or as dictionaries.

typeof returns 'object' for both; check arrays with Array.isArray.

Index vs key

array: ['a', 'b', 'c'] arr[1] → 'b'
object: { id: 7, name: 'Ada' } obj.name → 'Ada'

Practical examples

Array methods

[3, 1, 2].sort().map(n => n * 2)   // [2, 4, 6]

Object as record

const user = { id: 7, name: 'Ada' }
Object.keys(user)    // ['id', 'name']
Object.entries(user)

Detect arrays

typeof [] // 'object'
Array.isArray([]) // true

List of records

const users = [{ id: 1 }, { id: 2 }]
users.find(u => u.id === 2)

Common mistakes

  • Using typeof to detect arrays.
  • Using for…in on arrays.
  • Using an object when you need ordered, iterable data.

Key takeaways

  • Array = ordered list, object = named fields.
  • Arrays are objects with extras.
  • Use Array.isArray.

FAQ

Can arrays have string keys?

Technically yes, but do not.

Object vs Map?

Map allows any key type and keeps insertion order with size.

More JavaScript articles