What is the main difference between arrays and objects in JavaScript?
Arrays can store multiple values of any type, while objects store key-value pairs.
Arrays are ordered, while objects are unordered.
Arrays can be accessed using numerical indices, while objects are accessed using keys.
Arrays have a length property, while objects do not.
Arrays are a special type of object in JavaScript that are used to store multiple values in a single variable. Arrays can be accessed and manipulated using numerical indices, and they can store values of any type, including objects themselves. In contrast, objects in JavaScript are collections of key-value pairs, where each key is a string that maps to a value. Objects are accessed using the keys, and the order of the key-value pairs is not guaranteed.