Before ES6, Functions were written as :
greeting = function(){
return "This is webdevprojekts!";
}
With the introduction of Arrow Functions in ES6 :
greeting = () => {
return "This is webdevprojekts!";
}
Arrow Functions return value by default, thus it gets more shorter :
greeting = () => "This is webdevprojekts!";
Arrow Functions with parameter :
if you have parameters, you pass them inside the parantheses :
greeting = (name) => "This is webdevprojekts!" + name;
Arrow Functions with single parameter :
if you only have one parameter, you can skip the parantheses as well :
greeting = name => "This is webdevprojekts!" + name;
Top comments (0)