What is the fastest way to see if a node has a child with a specific tag in javascript? : I want to check if a node has a certain tag in itself or one of it's children in Javascript. 

    <html>
         <body>
             <p>
                 <h3><a> This link lead nowhere!</a> </h3>
             </p>
         </body>
    </html>

For example, in the above code, if I was given the node which is responsible for the p tag, and want to check if it has a link in it, what would be the fastest way to just check that (without having the actual node for the link)?

If the given node's name was "node", would it be faster to do:

    function nodeContainsTag(node) {
        return node.tagName == "A" || node.getElementsByTagName("a").length > 0 ;
    }
or

    function nodeContainsTag(node) {
        return node.outerHTML.indexOf("<a") > 0;
    }

Is the second function even guaranteed to work (i.e. do I need to check case sensitivity(`"<A"`) and spacing (ex: `"< a"`))?