title: What is the difference between querySelectorAll and getElementsByTagName?
body: <p>I was wondering about two different syntax of selecting element in JavaScript.</p>
  <p>suppose if I want to select all divs from current document then:</p>
  <pre><code>var divs = document.getElementsByTagName(&quot;div&quot;);
  console.log(&quot;There are &quot;+divs.length+&quot; Divs in Document !&quot;);
  </code></pre>
  <p>Will work fine. But there is also another way of doing so, like:</p>
  <pre><code>var divs = document.querySelectorAll(&quot;div&quot;);
  console.log(&quot;There are &quot;+divs.length+&quot; Divs in Document !&quot;);
  </code></pre>
  <p>When both of them works in the same way. What's the difference between them ?</p>
  
  <li>Which one is faster?</li>
  <li>Why?</li>
  <li>How both works?</li>
  <p>Thanks in advance. I've seen the questions like this but they didn't satisfied the need.</p>