javascript-enlightenment
javascript-enlightenment copied to clipboard
revise a note of promise then.
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