Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save unscriptable/4755409 to your computer and use it in GitHub Desktop.
Save unscriptable/4755409 to your computer and use it in GitHub Desktop.
var dfd, p1;
dfd = defer();
p1 = dfd.promise;
p1.then(null, function () { console.log('onRejected 1 failed'); });
p1.then(null, function () { console.log('onRejected 2 failed'); });
dfd.reject('wat');
// what will be the ouptut?
@avoidwork
Copy link

The question was more like this:

p1.then(function (arg) { throw Error(arg); }, null).then(null, function (e) { console.error(e.message); });
p1.then(function (arg) { console.log(arg); }, null);
p1.then(function (arg) { console.log("wat?"); }, null);
p1.resolve("what up");

thanks to the twitter convo I know the output will be:

what up
wat?
what up // Error on next tick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment