nzakas / understandinges6

Content for the ebook "Understanding ECMAScript 6"
5.45k stars 796 forks source link

Potential typo in 11 - Promises - Non-Promise Thenables #454

Closed ronen-e closed 1 year ago

ronen-e commented 3 years ago

Where Under the section "Non-Promise Thenables"

Problem

Both Promise.resolve() and Promise.reject() also accept non-promise thenables as arguments. When passed a non-promise thenable, these methods create a new promise that is called after the then() function.

Reason A promise object is not a function therefore it cannot be called. If the use of the term "call" here does not refer to a function call it is still confusing since in other parts of the book the term "call" refers to function calls.

Solution I believe the intent was to say the the new promise is settled after calling the then() function on the thenable object

So perhaps something like this:

When passed a non-promise thenable, these methods create a new promise that is settled after calling the then() method on the thenable object.

This is more in line with ECMAScript standard explanation for the inner workings of a promise object

https://www.ecma-international.org/ecma-262/11.0/index.html#sec-newpromiseresolvethenablejob

Screen Shot 2020-09-18 at 6 19 37 PM
nzakas commented 3 years ago

Yeah, your wording makes sense.