Most performant way to cast nodelist to array
/**
* Performant nodelist to array cast. Source: http://stackoverflow.com/a/15144269/370786
* @param nl {NodeList} NodeList to convert. Might work with other data types (Array?) but that needs further testing.
*/
function toArray(nl)
{
var arr = [];
if(isNaN(nl.length)) {
throw "Cannot get length";
} else {
for(var i=-1,l=nl.length;++i!==l;arr[i]=nl[i]);
}
return(arr);
}