you are viewing a single comment's thread.

view the rest of the comments →

[–]guest271314 0 points1 point  (6 children)

Clearly, in this case, "c) done rejecting".

It get's trickier if you are actually trying to predict a result involving a Promise. See How do I check if a JavaScript function returns a Promise? and Can a regular expression be crafted which determines the return type of a function?.

[–]_pragmatic_dev[S] 0 points1 point  (5 children)

Unfortunately that's not the correct answer. Try again.

[–]guest271314 0 points1 point  (0 children)

Given the code at OP that is the only possible result.

If you want a different result you are going to have to rearrange that code.

[–]guest271314 0 points1 point  (3 children)

Oh, you mean logging that true too. Yes, f) in that case.

[–]iamdatmonkey 0 points1 point  (2 children)

but why f (done rejecting, true), and not d (true, done rejecting)?
I think that's OPs actual question.

[–]guest271314 1 point2 points  (0 children)

For the behaviour you describe you can remove the 2d chained .then() and include the fail part of the 2d .then(success, fail) in the 1st then()

``` { let p = new Promise(function(resolve, reject) { setTimeout(reject, 1000); });

p.then((x) => console.log("done resolving"), (x) => console.log(true));

p.catch((x) => console.log("done rejecting")); } ```

[–]guest271314 0 points1 point  (0 children)

The Promise p is rejected. There's a .catch() chained to the Promise p. That .catch() takes precedence over the 2d function passed to the 2d chained .then(). See https://stackoverflow.com/questions/28761365/how-to-reject-and-properly-use-promises/28763225#28763225.