Using monocle mustache for chaining.
Brendan Eich
brendan at mozilla.com
Sat Nov 12 12:56:36 PST 2011
On Nov 12, 2011, at 12:22 PM, Axel Rauschmayer wrote:
> [Apologies for interrupting...]
No problem!
>> If we do classes, what .{ use-cases remain?
>
> The operator allows you to use object literals (including all of the niceties that will be introduced in ES.next) where you previously had to do multiple assignments. It’s especially nice for adding things to prototypes. For example:
>
> function Person(name) {
> this.name = name;
> }
> Person.prototype . {
> describe() {
> return "Person called "+this.name;
> }
> };
That's a good point -- it preserves .constructor, unlike assigning a fresh object literal to Person.prototype.
/be
More information about the es-discuss
mailing list