Map a NodeList to an array of properties.

The NodeList type does not implement the useful bits of the Array interface. This code essentially recreates the list into a regular array.

var nodes = document.querySelectorAll('a');
var urls = [].map.call(nodes, function(node) {
    return node.href;
});

Author: n1k0
Tags: array

comments powered by Disqus