Skip to content

Instantly share code, notes, and snippets.

@yoko
Created June 10, 2011 05:49
Show Gist options
  • Save yoko/1018299 to your computer and use it in GitHub Desktop.
Save yoko/1018299 to your computer and use it in GitHub Desktop.
JSDeferred and $.Deferred
var d;
// 1. JSDeferred風
d = Deferred
.next(function() {
console.log('next1', Deferred.isDeferred(this), this === d);
})
.next(function() {
console.log('next2', Deferred.isDeferred(this), this === d);
});
// "next1", true, false
// "next2", true, true
// 2. $.Deferred風
d = Deferred();
d
.next(function() {
console.log('next1', Deferred.isDeferred(this), this === d);
})
.next(function() {
console.log('next2', Deferred.isDeferred(this), this === d);
});
d.call();
// "next1", true, false
// "next2", true, false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment