I have made some progress with the syntax of objects in JavaScript but I am not clear about their use in the overall context of an application such as a shopping cart. I have read quite a lot on MDN’s website on OOP for JavaScript but seem to only have learnt details of implementation and not the overall structure of a program.
If I made a class for products then every instance would be a single product but would it be sensible to have lots of instances with different names eg product-1, product-2 etc. to me that seems worse than just having an array of products where each product is another array containing name, description, price etc. Does every instance have to have a name?
Also how would I iterate over all instances of a class? The only way I can think of is to add every instance, when it is constructed, to an array or object and then iterate that.
Would it be sensible in OOP to have a class representing the store which would contain all the instances of the product class which represent each product? Then I could have classes for orders, customers etc. Does this make sense?
I have seen a huge amount of material when I google this but always get bogged down in syntax when I start to read it. Any advice on this or pointers to really good literature on the subject or examples would be very useful.