In Promise there is a finally() - runs after all chains, error are done.

Anything similar in Array.forEach() ? May be needed when you want to do something at the end of the async stuff that happens on each of the array elements - when all are done.

This can be easily done by following:

ref

Using a basic counter

function callback () { console.log('all done'); }

var itemsProcessed = 0;

[1, 2, 3].forEach((item, index, array) => {
  asyncFunction(item, () => {
    itemsProcessed++;
    if(itemsProcessed === array.length) {
      callback();
    }
  });
});

Important to use a independent counter here: depending on the value of the index parameter does not provide the same guarantee, because the order of return of the asynchronous operations is not guaranteed.

More methods on the ref.