difference between array and object

Both "array" and "object" can be used to represent collections of data.
But what is the difference between them?
(1) Arrays represent collections of ordered data, while objects represent collections of unordered data .If
the order of the data is important, use an array, otherwise use an object.

(2) Another difference between an array and an object is that
the data of an array does not have a "name" (name), and the data of an object has a "name" (name) Also known as the key value, the
array retrieves data by position such as array[1], and the object retrieves data by key value such as var goods={a:1,b:s}
goods.a=1.

(3 ) But there is also an "associative array" in js. The data in this array has a name.
For example, in javascript, you can define an object like this:
var a={"city":"Beijing", "Area": ​​16800, "Population": 1600};
However, it can also be defined as an associative array:
a["City"]="Beijing";
a["Area"]=16800;
a["Population"]= 1600;
In the Javascript language, an associative array is an object, and an object is an associative array.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326663567&siteId=291194637