I have a general inquiry as a beginner in programming. I am trying to understand the best practices for utilizing objects and arrays.
Specifically, I am questioning whether it is preferable to strictly use objects as prototypes or if it is acceptable to store data within them.
For example, in my current project, I need to save images for future use. Right now, I have created an object like this:
var Images = {
james: "images/james.png",
karen: "images/karen.png",
mike: "images/mike.png"
};
Since I know the position of each image, I also considered storing them in an array and accessing them by index:
var images = ["images/james.png", "images/karen.png", "images/mike.png"];
images[0];
The object method functions correctly, but I am unsure about which approach is more appropriate. Is it dependent on the scenario? Are there performance implications that should be considered? Is there a standard practice that new programmers like myself should adhere to?
I appreciate any guidance you can provide. Thank you.