Skip to content

Instantly share code, notes, and snippets.

@ryansukale
Created June 28, 2015 01:36
Show Gist options
  • Save ryansukale/9cfeea81be5290f9b308 to your computer and use it in GitHub Desktop.
Save ryansukale/9cfeea81be5290f9b308 to your computer and use it in GitHub Desktop.
Fun with promises
Promise.resolve().then(function () {
return 100;
})
.then(function() {
console.log(arguments);
});
// ---
Promise.resolve(200).then(function () {
console.log(arguments);
return Promise.resolve(100);
})
.then(function(arg1) {
console.log(arguments);
});
// ---
Promise.resolve().then(function () {
return 100;
}).then(function () {
console.log('1', arguments);
})
.then(function() {
console.log('2', arguments);
});
// ---
Promise.resolve().then(function () {
return 100;
})
.then(null)
.then(null)
.then(null)
.then(function() {
console.log(arguments);
});
.then(null)
.then(function() {
console.log(arguments);
});
// ---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment