I am creating an array of objects. The array can have multiple same objects, so the final result would be something like:
MyArray = [obj1, obj1, obj2]
I want to count how many obj1 are in the array without declaring new variables since I want to use this method to store and count hundreds of different objects.
This is for an Angular web app to manage orders.
I was thinking of storing these objects as:
MyArray = [{obj1: 2}, {obj2: 1}]
but I can't figure out how to do it, nor how to increase the value when another obj is added.
Thanks in advance.