title: How to detect HTMLCollection/NodeList in JavaScript?
body: <p>I'm not sure my current implementation is available all the time:</p>
  
  <pre><code>function isNodeList(nodes) {
      var result = Object.prototype.toString.call(nodes);
      // modern browser such as IE9 / firefox / chrome etc.
      if (result === '[object HTMLCollection]' || result === '[object NodeList]') {
          return true;
      }
      //ie 6/7/8
      if (typeof(nodes) != 'object') {
          return false;
      }
      // detect length and item 
      if (!('length' in nodes) || !('item' in nodes)) {
          return false;
      }
      // use the trick NodeList(index),all browsers support
      try {
          if (nodes(0) === null || (nodes(0) &amp;&amp; nodes(0).tagName)) return true;
      }
      catch (e) {
          return false;
      }
      return false;
  }
  </code></pre>
  
  <p>A common situation is {length:1,item:function(){return [];}}<br/>
  The value of result in chrome / safari / opera is '[object NodeList]'.<br/>
  In firefox and IE 9 , it is '[object HTMLCollection]'.<br/></p>
  
  <p>Which is the standard value?</p>