Arrays are ordered, so you should use them when this is useful. You can iterate over them using a for look, for example.
In this particular example, this is not something that we would want to do. If we want to place the function in an array, we will have to refer to the values based on their index [0, 1, etc.]. There will be a big problem if we ever decide to add an additional key-value pair or change anything in the structure of the array once we have done that. Using an object, on the other hand, will be perfectly suited for the task. Hopefully this is making sense.
1
u/SandHK Mar 16 '21
thanks for the video. Using you example of hours and rate, what is the benefit of objects over arrays?