Subclassing ES6 objects with ES5 syntax.

C. Scott Ananian ecmascript at
Sat Apr 25 21:08:51 UTC 2015

On Sat, Apr 25, 2015 at 5:03 PM, Domenic Denicola <d at> wrote:

> There needs to be an unforgable brand property such that only objects
> created with `new XPromise()` pass `XPromise.resolve`. It is not a use case
> to allow building an object ES5 style in pieces to pass the brand check.
> Such objects should be coerced to real promises.

But can you give me an actual use case, please?  The ostensible security
property is pretty moot given `Object.setPrototypeOf`.

In this case, the promises *are* "real promises".  They were created with
`new Promise`.  But then the prototype was changed.  So in effect I've
forged the brand -- they are not actually `Promise` any more, they are
something else.

And I can forge this arbitrarily using Reflect.construct, which lets me set
`` (and thus [[PromiseConstructor]]`) to absolutely anything I

If the brand property is not actually unforgeable, what use is it?  It
seems like some broken piece of an idea that doesn't actually work.

But maybe it does work and serve a purpose -- that's why I'm asking: can we
point to someone who is actually using this functionality for a specific
purpose?  And is it working for them?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list