Last Updated: February 25, 2016
·
530
· mattcodez

jQuery Deffereds and Resolution Values

If you pass multiple Deffered objects into a jQuery $.when() call, the resolved values will all be passed as individual arguments to the then() callback. Ex.

$.when(
 $.Deferred(
    function(deff){
      deff.resolve(5);
    }
  ), 
 $.Deferred(
    function(deff){
      deff.resolve(7);
    }
 )
).then(function(){
 console.log(arguments);
});

Will output [5, 7] in the console. So presumably the order is based on the order in which the Deffered objects were added to the when list.