Occasionally, I need to collect pieces of text from an HTML page and run code like this in a browser console:
copy(
Array.from(document.querySelectorAll('h2'))
.map(h2 => h2.innerText)
.join('\n')
)
You can also map via the second optional parameter of Array.from(), but I find my version nicer to read (even though it’s less efficient).
https://exploringjs.com/impatient-js/ch_arrays.html#Array.from