Give meaningful names to Deferred/Promise variables
When using a Deferred or a Promise, don’t just call the variables “deferred” and “promise”. Take this simple example:
var promise = $.ajax(...);
promise.done(function (data) {
// Our fetching is done
});
This is an improvement:
var fetching = $.ajax(...);
fetching.done(function (data) {
// Our fetching is done
});
Try to use nouns or verbs that describe what the Deferred/Promise is actually “promising”. In the above example, it is the promise of the completion of a data fetch. That way your code reads more like natural language: “When the fetching is done …”.