Is this a correct way of defining a function in ecma6? ```javascript var bar = () =>{return "foo"}
I mean instead of ```var bar = function() {return "foo"}```
This is one ```javascript var bar = () => { return "foo" } ```
In javascript ``` var bar = function() { return "foo" } ```
Hello there 52 SS mod :D
do you need help? ^-^
JOLG, This is the site administrator, please leave this place... ._.
And yes this is a way you can define a function in ECMA6, Although, i'm not entirely sure why you would want to... Both ways would work in ECMA6.
Also, for further information about this, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
Alrighty, I've been looking for some more examples in case you need it... 1. https://www.nczonline.net/blog/2013/09/10/understanding-ecmascript-6-arrow-functions/ 2. http://www.2ality.com/2012/04/arrow-functions.html 3. http://stackoverflow.com/questions/22939130/when-should-i-use-arrow-functions-in-ecmascript-6 That should be enough to help you understand the functions, when to use them, and why to use them.
BTW, out of curiosity, why did you switch to a guest? ._.
Join our real-time social learning platform and learn together with your friends!