One of the advantages I've heard for the use of forEach
vs a for/of
on an iterable is that you can chain methods together.
As a basic example of the two I have:
let arr = [1,2,3];
arr.forEach((elem, idx) => {
console.log(elem);
})
for (let elem of arr) {
console.log(elem);
};
What would be an example of chaining together multiple forEach
's?