VOOZH about

URL: https://www.geeksforgeeks.org/javascript/are-javascript-arrays-objects/

⇱ Are JavaScript arrays objects - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Are JavaScript arrays objects

Last Updated : 11 Jun, 2026

Yes, JavaScript arrays are actually specialized objects, with indexed keys and special properties. They have a length property and are technically instances of the Array constructor.

You can add non-integer properties to arrays, making them work partly like objects. However, this is usually discouraged for clarity.


Output
MyArray
0: 1
1: 2
2: 3
name: MyArray

Reason to not recommended to treat arrays like normal objects and add properties

Adding non-integer properties to arrays can lead to unexpected issues:

  • Arrays are typically used to store ordered lists, so adding properties may make code harder to understand.
  • Some iteration methods, like for...in, will include these properties, which might cause bugs.
  • Many array methods (like map, filter, and forEach) only work on elements with numeric indices, so the extra properties won’t be included in these operations.

In general, if you need additional properties, it’s better to use an object or another structure instead.



Comment