+ 10
FatArrow in JavaScript
I heard of it !! But I dont know How to use it yet !! plz help!!
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.