title: Why can't I chain this series of lodash calls?
body: <p>This code:</p>
  
  <pre><code>  _(gameState.loot)
    .pick((value, key) -&gt; key isnt "pickUpAnimations")
    .filter ((d) -&gt; _.isArray (d))
    .reduce ((sum, d) -&gt; sum.concat (d))
  </code></pre>
  
  <p>Is giving me this error:</p>
  
  <pre><code>TypeError: 'undefined' is not a function (evaluating '(function(d) {
  </code></pre>
  
  <p>Whereas this code works fine:</p>
  
  <pre><code>  removedAnimations = _.pick(gameState.loot, (value, key) -&gt; key isnt "pickUpAnimations")
    removedAnimations = _.filter removedAnimations, ((d) -&gt; _.isArray (d))
    removedAnimations = _.reduce removedAnimations, ((sum, d) -&gt; sum.concat (d))
    removedAnimations
  </code></pre>
  
  <p>To me it seems that these should be doing the same thing.  The schema of <code>gameState.loot</code> looks like this:</p>
  
  <pre><code>loot: {
    ttl: 6000
    slowBlinkWhenTtlLessThanPercent: 60
    fastBlinkWhenTtlLessThanPercent: 30
    resurrections: []
    gold: []
    health: []
    equipment: []
    pickUpAnimations: []
  }
  </code></pre>
  
  <p>BTW, this is the javascript being generated from the first example:</p>
  
  <pre><code>return _(gameState.loot).pick(function(value, key) {
    return key !== "pickUpAnimations";
  }).filter((function(d) {
    return _.isArray(d);
  }).reduce((function(sum, d) {
    return sum.concat(d);
  })));
  </code></pre>
  
  <hr>
  
  <p>I tried @Blender's suggestion of this:</p>
  
  <pre><code>  _(gameState.loot)
      .pick (value, key) -&gt; key isnt "pickUpAnimations"
      .filter (d) -&gt; _.isArray (d)
      .reduce (sum, d) -&gt; sum.concat (d)
  </code></pre>
  
  <p>But that gave me this error: </p>
  
  <pre><code>&gt;&gt; TypeError: 'undefined' is not a function (evaluating '"pickUpAnimations".filter(function(d) {
  </code></pre>
  
  <p>Here's how the javascript looks like:</p>
  
  <pre><code>return _(gameState.loot).pick(function(value, key) {
    return key !== "pickUpAnimations".filter(function(d) {
      return _.isArray(d.reduce(function(sum, d) {
        return sum.concat(d);
      }));
    });
  });
  </code></pre>