Convert NodeList to Array quickly

• 1 min read

Convert NodeList to Array quickly

Found here and repost in this blog for easier reminder to myself.

var array = [].slice.call(document.querySelectorAll("div"))

This comes in handy from time to time.

Update #

There’s a more natural and easier-to-remember way to do the same task:

var array = Array.from(document.querySelectorAll("div"))