In situations of storing sets of values, should objects really be used in Javascript? In this case, I don't see an advantage of using an object over using an array. Although logic dictates its only preference, I can't shake the feeling that there's something I don't see.
Here is my example. Lets say we have have a bunch of cars, each car contains data with a specific format:
{
model: '';
color: '';
max_speed: '';
}
And we have a few functions, for which the (somewhat terse) pseudo code is:
function compareCarSpeeds(a, b){
if a is faster than b then
return a
else
return b
}
function findFastestCar(){
loop through all cars and return car with greatest speed
}
The OOP way would be create an object for car, maybe convert compareCarSpeeds into a prototype.
While the array way would be to create a 2D array, where one dimension is for the list of cars, and the second is for the set of data inside each car.