title: Get results from multiple deferred and pass to function
body: <p>I have a function like this to process some array of data:</p>
  
  <pre><code>function ProcessItems(data){
      var def = $.Deferred();
      var results = [];   
      $.each(data, function(v, k)
      {
          // GetItem(k) returns promise
          results.push(GetItem(k));
      });
      return $.when.apply(null, results);
  }
  </code></pre>
  
  <p>where i'm trying to get some items with GetItem(k) function and then i want to return selected data and pass it to function like this:</p>
  
  <pre><code>// data -&gt; JSON array, results -&gt; array of promises
  ProcessItems(data).then( function(results) { return ShowItems(results); } )
  </code></pre>
  
  <p>and display it using following function:</p>
  
  <pre><code>function ShowItems(items) {
      // here items have no data, but only a promise objects
      var def = $.Deferred();
      $.each(items, function(v, k)
      {
          alert(k);
      });
      def.resolve();
      return def.promise();
  }
  </code></pre>
  
  <p>I know that i can get my data from arguments here</p>
  
  <pre><code>$.when.apply(null, results).then(function() {
      // arguments[0] etc &lt;= data is here
  });
  </code></pre>
  
  <p>But how to pass it to the next function?</p>