Is there a way to execute a method that doesn't require arguments and doesn't return anything on each object within an array of objects that are all the same type? I've been trying to find a solution without resorting to using a traditional for loop like the one shown below:
for (let i = 0; i < list.length; i++) {
list[i].someMethod();
}
I've explored options such as Array.forEach
(and ruled out Array.map
), experimented with passing the method name as a string, and attempted to use call
while accessing the prototype method from one of the objects. Despite reading up on this topic from various sources, I haven't found a straightforward way to achieve this where each call is correctly bound to the appropriate this
. Can anyone suggest a technique that I may have missed?