title: jQuery Deferred's, $.when() and the fail() callback arguments
body: <p>I'm getting an unexpected result when using <code>$.when()</code> when one of the deferred operations does not succeed.</p>
  
  <p>Take this JavaScript, which created 2 deferreds. The first one succeeds and the second one fails. </p>
  
  <pre><code>var f1 = function() {
      return $.Deferred(function(dfd) {
          dfd.resolve('123 from f1');
      }).promise();
  };
  
  var f2 = function() {
      return $.Deferred(function(dfd) {
          dfd.reject('456 from f2');
      }).promise();
  };
  
  $.when(f1(), f2())
      .then(function(f1Val, f2Val) {
          alert('success! f1, f2: ' + JSON.stringify([f1Val, f2Val]));
      })
      .fail(function(f1Val, f2Val) {
          alert('fail!    f1, f2: ' + JSON.stringify([f1Val, f2Val]));
      });
  </code></pre>
  
  <p>Run it yourself: <a href="http://jsfiddle.net/r2d3j/2/" rel="noreferrer">http://jsfiddle.net/r2d3j/2/</a></p>
  
  <p>I get <code>fail!    f1, f2: ["456 from f2", null]</code></p>
  
  <p>The problem is that in the <code>.fail()</code> callback the value passed with the <code>f2()</code> rejection, is being routed to the first argument, where i expect the <code>f1Value</code>.  Which means that I don't really have a way of know which deferred object actually posted that <code>reject()</code>, and I also dont know which operation that failure data actually belongs to.</p>
  
  <p>I would have expected that <code>.fail()</code> would get arguments <code>null, '456 from f2'</code> since the first deferred did not fail.  Or am I just not doing deferreds right way here?</p>
  
  <p>How do I know which deferreds failed, and which rejection arguments belong to which failed deferred if the argument order in the callback is not respected?</p>