Shorter syntax for arrow function assignment

J Decker d3ck0r at gmail.com
Wed Oct 25 14:11:32 UTC 2017


On Wed, Oct 25, 2017 at 4:57 AM, T.J. Crowder <
tj.crowder at farsightsoftware.com> wrote:

> On Tue, Oct 24, 2017 at 6:26 PM, dante federici
> <c.dante.federici at gmail.com> wrote:
> >
> > So, something like:
> > ```
> > myFn() {
> > }
> > ```
> >
> > Would be considered as:
> > ```
> > var myFn = function() {
> > }
> > ```
> >
> > with what semantics exist now. Not best practices, but what is
> > currently interpreted in the language.
>
> No, it isn't. It's a `SyntaxError: Unexpected token {`. There's a big
> difference between `myFn() { }` and `myFn = function() { };` The latter is
> valid syntax for the horror of implicit globals (in loose mode; strict mode
> fixed it). The former is just a syntax error. (It would be valid method
> syntax if it were inside an object initializer or `class`.)
>

ya this is not a syntax error.
myFn()
{
}


> But AFAIK, Brian Blakely wasn't promoting that syntax anyway. His original
> post only ever uses this shorthand with `export`, so I think it was meant
> to be specific to exporting.
>
> -- T.J. Crowder
>
> _______________________________________________
> 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/20171025/5f430b88/attachment.html>


More information about the es-discuss mailing list