Wrong Promise.prototype.finally() description
MDN URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally
What specific section or headline is this issue about?
Description
What information was incorrect, unhelpful, or incomplete?
There are 2 paragraphs in the Description where I found to be misleading due to the fact that I tried to execute those expressions and the output is not as mentioned:

What did you expect to see?
- When I executed
Promise.reject(3).then(() => {}, () => 88), it returns a fulfilled promise with the value88(not "return a rejected promise with the reason88" as mentioned in the section):
Which matches the return value of the Promise.prototype.then() method:

- The
Promise.reject(3).finally(() => throw 99)actually throws an uncaught exception:
Which I believe just a typo. Can be fixed by adding a pair of curly braces: Promise.reject(3).finally(() => {throw 99});
- The execution of
Promise.reject(3).finally(() => Promise.reject(99))actually returns a rejected promise with the reason99:
Which abides by the return value of the Promise.prototype.finally() method:

- Assuming the typo from
Promise.reject(3).finally(() => throw 99)is fixed (because if it were intended to be syntactically wrong, the author should've mentioned that), the phrasing with "either...or" isn't the right choice of words, because they BOTH will return a promise that is rejected and has a value of99.
Do you have any supporting links, references, or citations?
Already listed above.
Do you have anything more you want to share?
I'm still learning Promise and its related topics so I'm unable to formulate a definitive example for that case. I'd like the reviewers to have their insights on this and maybe come up with a better code sample to ease in the reading process.
MDN metadata
Page report details
- Folder:
en-us/web/javascript/reference/global_objects/promise/finally - MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/javascript/reference/global_objects/promise/finally/index.md
- Last commit: https://github.com/mdn/content/commit/4e4ec5dbe15ae4883201057aaab8833dd33b7a05
- Document last modified: 2022-06-30T11:02:34.000Z
Can I work on this?
@hiteshvijayhv Yes please :ok_hand:
If you have any practical examples to signify the use cases of this particular event:

Then your contribution is definitely most welcomed :sparkles:
Yes, the first one is definitely wrong—the onRejected handler returning normally would still cause the promise to fulfill.
@Josh-Cena Most definitely. As a learner, I found those statements very confusing.
@hiteshvijayhv Yes please 👌 If you have any practical examples to signify the use cases of this particular event:
Then your contribution is definitely most welcomed ✨
From what I found is that finally() is used to place the code that is executed after the Promise is executed and we want to free up the resources. And this is what that is mentioned there in the docs.
I think this issue is for correcting the doc error instead of addition of more examples.
I will open a new issue regarding the practical implementation of finally()
@hiteshvijayhv Sure. Let's make the document better for the fellow learners.
I will make a new PR with all fix sorry for messing up
No worries. Keep up the good work 💯
No worries. Keep up the good work 💯
Thanks a lot.