Object method shorthand after initial declaration
# James Kyle (8 years ago)
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; }
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># Brian Blakely (8 years ago)
Is it only valid with a semicolon after foo(), though? Pragma without
semicolon throws in three engines.
Is it only valid with a semicolon after `foo()`, though? Pragma without
semicolon throws in three engines.
On Tue, Oct 24, 2017 at 2:41 PM, James Kyle <me at thejameskyle.com> wrote:
> 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/e87170a2/attachment-0001.html># /#!/JoePea (8 years ago)
obj.foo() {} is a syntax error in Chrome, so it seems possible to
make that a function definition.
/#!/JoePea
`obj.foo() {}` is a syntax error in Chrome, so it seems possible to
make that a function definition.
/#!/JoePea
On Tue, Oct 24, 2017 at 12:45 PM, Brian Blakely
<anewpage.media at gmail.com> wrote:
> Is it only valid with a semicolon after `foo()`, though? Pragma without
> semicolon throws in three engines.
>
> On Tue, Oct 24, 2017 at 2:41 PM, James Kyle <me at thejameskyle.com> wrote:
>>
>> 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
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
># Jordan Harband (8 years ago)
The following style (although not one I prefer) would have to also work as a function definition:
obj.foo()
{
}
The following style (although not one I prefer) would have to also work as
a function definition:
```
obj.foo()
{
}
```
On Tue, Oct 24, 2017 at 1:41 PM, /#!/JoePea <joe at trusktr.io> wrote:
> `obj.foo() {}` is a syntax error in Chrome, so it seems possible to
> make that a function definition.
> /#!/JoePea
>
>
> On Tue, Oct 24, 2017 at 12:45 PM, Brian Blakely
> <anewpage.media at gmail.com> wrote:
> > Is it only valid with a semicolon after `foo()`, though? Pragma without
> > semicolon throws in three engines.
> >
> > On Tue, Oct 24, 2017 at 2:41 PM, James Kyle <me at thejameskyle.com> wrote:
> >>
> >> 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
> >
> >
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
> >
> _______________________________________________
> 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/cc04dfa5/attachment.html>
Extend the method shorthand syntax beyond initial object declaration.
const obj = {}; obj.foo() {...}Equivalent 2015 syntax:
const obj = { foo() {...} };This is nice for assignment to context:
function Foo() { this.bar() {...} this.baz() {...} } const foo = new Foo(); foo.bar(); foo.baz();Equivalent 2015 syntax:
function Foo() { this.bar = function() {...}; this.baz = function() {...}; }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() {...}; } ``` -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171024/8530184a/attachment.html>