Frankie Bagnardi (2014-12-13T10:20:23.000Z)
You're much better off subclassing menu for that purpose.

class Menu
    constructor(options) {
        this.options = Object.assign({hidden: false}, options);
    }
}

class HiddenMenu extends Menu {
    constructor(options){
        super(Object.assign({hidden: true}, options));
    }
}


On Sat, Dec 13, 2014 at 2:54 AM, Glen Huang <curvedmark at gmail.com> wrote:

> But allowing getter & setter already makes it dangerous:
>
> let _bar = {}
> class Foo {
>         static get bar() { return _bar; }
> }
>
> Objects that have Foo.prototype in the prototype chain can do "this.bar.a
> = 1", and the change won’t be shadowed.
>
> I found myself looking for a way to define static properties because I
> want to do this:
>
> function Menu(options) {
>         this.options = Object.assign({}, Menu.defaults, options);
> }
> Menu.defaults = { hidden: false };
>
> I want to expose the defaults property so it can be modified by users.
> This pattern is very ubiquitous in es5. I wonder if the class syntax could
> allow this pattern to be carried to es6?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141213/1b1f6f6f/attachment.html>
d at domenic.me (2014-12-19T22:48:35.912Z)
You're much better off subclassing menu for that purpose.

```js
class Menu
    constructor(options) {
        this.options = Object.assign({hidden: false}, options);
    }
}

class HiddenMenu extends Menu {
    constructor(options){
        super(Object.assign({hidden: true}, options));
    }
}
```