Is there a shortcut to create an array of links in JavaScript without using a loop?
var links = document.links;
Instead of looping through the array to find elements with href attribute equal to '/somehref', is there a way to directly filter those elements like:
var links = document.links[href='/somelink']
This would eliminate the need for a for loop. Also, I want to efficiently return instances of both <a>
and <button>
elements with href='/somelink' into one array. Any suggestions on achieving this lazily and efficiently?