I stumbled onto this neat shortcut for converting a DOM NodeList into a regular array, but I must admit, I don't completely understand how it works:
[].slice.call(document.querySelectorAll('a'), 0)
So it starts with an empty array []
, then slice
is used to convert the result of call
to a new array yeah?
The bit I don't understand is the call
. How does that convert document.querySelectorAll('a')
from a NodeList to a regular array?