title: document.getElementsByTagName doesn't work. How can I get the length of NodeList of body?
body: <p>I want to get the length or item of body tag.
  But, It seems getElementsByTagName doesn't work in terms of NodeList.
  How can I do that?</p>
  
  <pre><code> &lt;script type=text/javascript&gt;
   var b = document.getElementsByTagName('body');                                                                                                                            
   console.log(b);         // &lt;body&gt;...&lt;/body&gt;
   console.log(b.length);  // 0    
   console.log(b[0]);      // undefined
   console.log(b.item(0)); // null
   &lt;/script&gt;
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>[Edit]
  I added entire body.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type=text/javascript&gt;
   var b = document.getElementsByTagName('body');                                                                                                                            
   console.log(b);         // &lt;body&gt;...&lt;/body&gt;
   console.log(b.length);  // 0    
   console.log(b[0]);      // undefined
    console.log(b.item(0)); // null
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id='test'&gt;
  &lt;h2&gt;Hello&lt;/h2&gt;
  &lt;p&gt;test&lt;/p&gt;
  &lt;p&gt;test&lt;/p&gt;
  &lt;p&gt;test&lt;/p&gt;
  &lt;p&gt;test&lt;/p&gt;
  &lt;p&gt;test&lt;/p&gt;
  &lt;p&gt;test&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>