+ 10

FatArrow in JavaScript

I heard of it !! But I dont know How to use it yet !! plz help!!

27th Jan 2018, 5:46 PM
I'm_Groot
I'm_Groot - avatar
1 Answer
+ 8
fat arrows were introduced in ES6 and are simply another syntax for writing functions https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/ function add(a, b){ return a + b; } can become either var add = (a, b) => a + b; OR var add = (a, b) => { return a + b; } notice that in the first option we do not use "return" statement. when having curly braces as in the second option, a return statment is needed. and on a side note, you shouldn't use fat arrow functions in the code playground, as not all mobile phone will support it.
27th Jan 2018, 7:59 PM
Burey
Burey - avatar