title: How do I use array reduce to sum object property lengths w/o typeof
body: <p>I have an array of objects each containing an array of other objects. I would like to use reduce to sum the lengths of all of these arrays. To do this I seem to have to provide a <code>typeof</code> check first like this...</p>
  
  <pre><code>var totalTasks = $scope.list.reduce(function(a, b){
    var aNum = 0, bNum = 0;
    if(typeof a === "object" &amp;&amp; a.subItems){
        aNum = a.subItems.length
    }
    else{
        aNum = a
    }
    if(b.subItems) {
        bNum = b.subItems.length;
    }
    return aNum + bNum;
  });
  </code></pre>
  
  <p>It seems like there has to be a way to do this without the typeof. Any ideas?</p>