result Promise a result in the future Can be passed to other functions Of course promises are in jQuery as well, though they behave slightly differently.
} So let's say we have a function that is asynchronous and should return a promise. Construct the deferred at the top of the function, and return the promise at the end.
deferred.resolve("again!"); // Unless strict mode is desired: deferred.resolve("again!", true); Same for reject(), progress() and cancel(). With the old Deferred this throws an error.
passed a value, without catching errors // thrown by callback. Does not return a // promise. when(value, function(value){ throw new Error(); }); // Throws!