There is no need to do that. Each array element is an object with the properties of year and type, their order is of no issue here, you get each object by their array index, e.g.
cars[0]
for the first object. To get the respective properties of the an element, say the 2nd elements,
cars[1].type
and
cars[1].year
Learn
JavaScript Objects[
^]