Dla ... z ... pętli i godelistów

const elements = document.querySelectorAll('.foo');

for (const element of elements) {
    element.addEventListener('click', doSomething);
}
Enchanting Echidna