Promise() vs. new Promise()

Tab Atkins Jr. jackalmage at gmail.com
Thu Aug 21 07:16:40 PDT 2014


On Thu, Aug 21, 2014 at 2:03 AM, Andrea Giammarchi
<andrea.giammarchi at gmail.com> wrote:
> This is also a precedent that suggest `Object.create(Generic.prototype)` is
> useless when the `Generic` is ES6 class due inability to initialize it later
> on: a very "bad news" for prototypal inheritance.
>
> Accordingly, interoperability with old code (the "one JS" myth) is
> compromised and prototypal inheritance won't be "fully portable" with
> user-land classes.
>
> Latter is not necessarily unexpected since we know other cases that could
> fail, i.e.
>
> ```js
> var a = Object.create(Array.prototype);
> Array.call(a, 1, 2, 3);
> a; // still empty
>
> Array(1, 2, 3); // [1,2,3]
> ```

I don't generally see this kind of "inheritance" used; it seems like a
weird way to say "var a = new Array(1, 2, 3);".

I do commonly see code like:

```
function Foo() {
 ...
}
Foo.prototype = Object.create(Bar.prototype);
```

Which always works and will continue to work in the future.

~TJ


More information about the es-discuss mailing list