Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revise a note of promise then. #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zjffun
Copy link

@zjffun zjffun commented May 10, 2020

I'm not sure if I misunderstood this note. According to:

https://tc39.es/ecma262/#sec-performpromisethen

Else if promise.[[PromiseState]] is fulfilled, then
---Let value be promise.[[PromiseResult]].
---Let fulfillJob be NewPromiseReactionJob(fulfillReaction, value).

https://tc39.es/ecma262/#sec-newpromisereactionjob

If handler is undefined, then
---If type is Fulfill, let handlerResult be NormalCompletion(argument).

if you don't provide then() a non-function, the next then() resolve function will passed the value the current resolve function passed.

eg:

> Promise.resolve(42).then(24).then(d => console.log(d))
// 42

> Promise.resolve(42).then({}, ()=>{}).then(d => console.log(d))
// 42

> Promise.resolve(42).then().then(d => console.log(d))
// 42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant