Is there an elegant way of calling a method on each object in an array without iteration?
Edit: The intent of the question was to ask "without a for loop, or without any iteration if possible" Sorry for the confusion
var dogs = [new Dog("Max"), new Dog("Buddy"), new Dog("Charlie")];
for(var i=0; i<dogs.length; i++){
dogs[i].sayName();
}
function Dog(name){
this.name = name;
this.sayName = function(){
console.log(this.name);
}
}
dogs.forEach(dog => dog.sayName());?forEach()a form of iteration?