jQuery has a bad habit of ruining the logic of arguments. In your case, a simple loop will normalize it if you want a callback for each deferred object:
$.each(dfds, function() { $.when(this).done(function() { console.log(arguments); }); });
You can also loop arguments, so you don't have to send an array:
function foo() { $.each(arguments, function() { $.when(this).done(function() { console.log(arguments); }); }); }
UPDATE
If you always want to return an array of a pending object, you probably need to check the length of the arguments in foo , as Felix posted, or do something like:
function foo() { $.when.apply(this, arguments).done(function() { var args = $.makeArray(arguments), result = args[0].constructor != Array ? [args] : args; console.log(result); }); }
http://jsfiddle.net/2ht8d/
source share