News for hackers. Stuff that matters.
Re:ES6 is beautiful by serpix on Thursday April 07, 2016 @02:58PM (#11449668)
I recently witnessed the absurdity of arrow functions NOT returning implicitly if you put the function body in {}. It's a shit show.
Re:ES6 is beautiful by btdiehr on Thursday April 07, 2016 @03:04PM (#11449727)
If you want to return an object literal just do this,

`(text) => ({ label: text })`

In my opinion the arrow function has great syntax. Rest assured, no matter what the syntax was chosen to be, there would be an extremely vocal group of people who hate it (such as yourself).

Re:ES6 is beautiful by rimunroe on Thursday April 07, 2016 @03:01PM (#11449701)
That actually is one of my favorite things about arrow functions next to the no-changing-this aspect. I find CoffeeScript's optional return statement really awkward to read for anything that isn't a one-liner. I don't want to have side-effectful functions return values, and dropping bare statements in in order to accomplish that seems extra noisy.
Re:ES6 is beautiful by rhinoceraptor on Thursday April 07, 2016 @03:05PM (#11449728)
That's part of the spec, they're really meant for doing functional style, one liner type of things, like

[1, 2, 3, 4].map(x => x + 1)

You should probably avoid using them for other applications, particularly if you're using a library that uses prototypes because it won't work.

Re:ES6 is beautiful by douche on Thursday April 07, 2016 @03:11PM (#11449778)
If that's what they are for, why call them "arrow functions", and not lambdas like everybody else does?
Re:ES6 is beautiful by TheCoelacanth on Thursday April 07, 2016 @04:47PM (#11450580)
To distinguish from javascript's other longer way of writing the same thing:

    [1, 2, 3, 4].map(function (x) { return x + 1; })
Re:ES6 is beautiful by rhinoceraptor on Thursday April 07, 2016 @04:31PM (#11450456)
Javascript already had lambdas/anonymous functions since the beginning.