@@new

C. Scott Ananian ecmascript at cscott.net
Wed Jun 18 12:39:05 PDT 2014


On Wed, Jun 18, 2014 at 3:08 PM, Allen Wirfs-Brock
<allen at wirfs-brock.com> wrote:
> I think that fact that these really are semantically equivalent:
>
>  function F(x) {this.foo=x};
>  class F  {constructor(x) {this.foo=x}};
>
> is pretty important to the evolutionary nature ES6 classes.

That's the easy case.  The `class F` version in Jason's proposal
invokes a superclass constructor, but that does nothing so it's all
the same.

The harder question is:
```
function F(x) { this.x = x; }
function G(y) { this.y = y; }
G.prototype = new F;
```
vs
```
function F(x) { this.x = x; }
class G extends F { constructor(y) { this.y = y; } }
```
  --scott


More information about the es-discuss mailing list