How come resolving a settled Promise doesn't throw?

/#!/JoePea joe at trusktr.io
Tue Feb 28 18:12:04 UTC 2017


f.e.

```js
let resolve
let p = new Promise(r => resolve = r)

resolve(5) //  resolves the promise.
resolve(4) // noop (in Chrome), but why not throw an error?
```

I only tested in Chrome, and I'm assuming it follows spec, but I could be
wrong.

I'm asking because it seems that throwing an error will prevent shots in
the foot, so that code doesn't assume that resolving on an already resolved
Promise worked, although it didn't. It seems like it can lead to unexpected
failures.


*/#!/*JoePea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170228/5bdb09ec/attachment.html>


More information about the es-discuss mailing list