[deleted]
> .then() does not create a new promise
The docs for Promise say that then() returns a promise. Are you saying it returns the original promise (ie. this)?
> But if your call to then isn't a Promise or a function that returns a Promise, your chain ends.
I don't think this is correct. The docs show examples of chains of then() calls where the intermediate function isn't returning a promise. See "chaining": https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
> .then() does not create a new Promise
It returns a promise, right?
> var foo = Promise.resolve([1,2,3]).then(function() { return 5 })
> foo
< Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: 5}I'd think it would return the original promise, for chaining.
No, it returns a new Promise that's already been resolved to the value you returned previously.
Not quite :) See my paste above, it returns a new Promise in pending state that will return the value in the new then block ("5" here), possibly immediately. (i.e. pending for one event loop tick, then resolved)