Object method shorthand after initial declaration

James Kyle me at thejameskyle.com
Tue Oct 24 18:41:03 UTC 2017


To parse it that way would be changing behavior.

obj.foo() {}
this.bar() {}

Are both call expressions followed by a block. They are valid syntaxes
today.

Think:

obj.foo();
{
let a = 1;
}


On Wed, 25 Oct 2017 at 4:29 am, Brian Blakely <anewpage.media at gmail.com>
wrote:

> Extend the method shorthand syntax beyond initial object declaration.
>
> ```js
> const obj = {};
>
> obj.foo() {...}
> ```
>
> Equivalent 2015 syntax:
>
> ```js
> const obj = {
>   foo() {...}
> };
> ```
>
> This is nice for assignment to context:
>
> ```js
> function Foo() {
>   this.bar() {...}
>   this.baz() {...}
> }
>
> const foo = new Foo();
> foo.bar();
> foo.baz();
> ```
>
> Equivalent 2015 syntax:
>
> ```js
> function Foo() {
>   this.bar = function() {...};
>   this.baz = function() {...};
> }
> ```
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171024/19feec1c/attachment.html>


More information about the es-discuss mailing list