On Mar 23, 2012, at 1:17 PM, Brendan Eich wrote:
> class Point extends Evil {
> constructor(ax, ay) {
> public x, y;
> super();
> this.x = ax;
> this.y = ay;
> }
> ...
> }
>
> class Evil {
> constructor() {
> console.log(this.x);
> }
> }
>
> Should undefined by logged, or an error thrown? ...
>
> I think we can -- it seems obvious to me.
>
> ... "no, error thrown". I don't agree with that, it's not how writable
> properties on objects work in JS.
+1
That kind of protection matters if you're trying to define a statically typed
class system that can guarantee all properties are initialized before use,
e.g., to have non-nullable types. That's not what we're doing here. We are
doing classes as a codification of existing practice. So you can refer to
properties before they've been initialized, and you get undefined.
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss