Once JavaScript has iterator helper methods (*), this code becomes:
copy(
document.querySelectorAll('h2')
.values()
.map(h2 => h2.innerText)
// Alas, there is no .join()
// Roughly equivalent:
.reduce((str, elem) => str+elem+'\n')
)