JavaScript Arrow Function

1/21/2020 4:55:03 AM

Arrow function like a regular function but it is simple for use the programmer. The structure is change of the arrow function. The arrow functions no need to use “function” keyword also no need to use function body. If we want, we don’t use “return” keyword. Arrow function use the arrow symbol   like ”=>”. If we use arrow function our code will vary clear and more read able for programmer. If we work with “Angular.js”, ”Node.js” etc then arrow function is very important for you. Now given bellow the example code and explain the code: 

<!DOCTYPE html>
<script type="text/javascript">
//Regular fynction
var myName=function(name){
return "My Name Is "+ name;
console.log(myName("Farhan Sakib"));
//Arrow Function
var myName=(name)=> "My Name Is "+ name;
console.log(myName("Farhan Sakib"));

First, we use the regular function to understand that what is arrow function. We can compare   the regular function and arrow function. Arrow function just one line of code and also same work like regular function.