Clarification for derived promises

Nicholas C. Zakas standards at nczconsulting.com
Tue Jul 14 17:09:51 UTC 2015


Hi all,

I'm trying to wrap my head around derived promises and wanted to ask for 
a bit of clarification around how `Promise.resolve()` works from a 
derived class. Consider this:

```
class MyPromise extends Promise {}

var p1 = new Promise(function(resolve, reject) {
     resolve(42);
});

var p2 = MyPromise.resolve(p1);
p2.then(function(value) {
     console.log(value);
});
```

Am I correct in believing that:

1. `p1` is resolved upon being passed to `MyPromise.resolve()`? I 
believe this is what happens in 25.4.4.5 Step 6 
(http://www.ecma-international.org/ecma-262/6.0/#sec-promise.resolve)
2. `p2` is an instance of `MyPromise` that is resolved with a promise 
value of 42.

Thanks!

-- 
___________________________
Nicholas C. Zakas
http://www.nczonline.net



More information about the es-discuss mailing list