title: Check if object is collection/iterable?
body: <p>I have to initialize a collection of objects in constructor and I wanted to support all collection types, such as Arrays, Maps, and Sets. <code>typeof</code> will only return Object and there doesn't seem to be a generic <code>Collections</code> utility object that would provide a function like <code>Array.isArray()</code>. </p>
  
  <p>Coming from Java and classical inheritance styles, my next impulse was to check the object's inheritance.  However, my experiments with various prototype functions didn't turn up anything.  The best I could figure out was to create a function that checks <code>.prototype.isPrototypeOf(object)</code> for Map, Set, and Array.  But that might be because I don't actually understand Javascripts prototypal inheritance.</p>
  
  <p>Is there a better way to check if an object is a collection?</p>