I think it might be problematic, since (if it works the same way as arrow
functions currently do) 'this' will refer to the context in which the class
was defined, and not to the instance that the function is attached to. And
if it doesn't need to access the instance, then it doesn't really need to
be an instance method anyway.
However if there was a shorthand for regular functions, then this still
might be solvable by allowing key : value pairs in the class definition.
It's only one more character than your proposal (the ':'), and would allow
for values other than shorthand functions to be defined
class MyClass {
deleteProfileImage : () -> (...) //or some other new shorthand for
regular functions
isMyClass : true
static myStaticMethod : () =>(...)
}
instead of
class MyClass {
deleteProfileImage(){
return ...
}
}
MyClass.prototype.isMyClass = true
MyClass.myStaticMethod = () => (...)
On Fri, May 5, 2017 at 12:13 PM, somonek <[email protected]> wrote:
> Hi,
>
> I this return shorthand would be helpful.
>
> class MyClass {
> deleteProfileImage() => (....)
> }
>
> as we already have this
>
> const myFunction = () => (....);
>
>
> any thoughts?
>
>
> Serghei
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss