![]() |
VOOZH | about |
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.
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:
In general, if you need additional properties, it’s better to use an object or another structure instead.