1//If body has single statement
2let myFunction = (arg1, arg2, ...argN) => expression
3
4//for multiple statement
5let myFunction = (arg1, arg2, ...argN) => {
6 statement(s)
7}
8//example
9let hello = (arg1,arg2) => "Hello " + arg1 + " Welcome To "+ arg2;
10console.log(hello("User","Grepper"))
11//Start checking js code on chrome inspect option
1// The usual way of writing function
2const magic = function() {
3 return new Date();
4};
5
6// Arrow function syntax is used to rewrite the function
7const magic = () => {
8 return new Date();
9};
10//or
11const magic = () => new Date();
12
13
1const plantNeedsWater = day => day === 'Wednesday' ? true : false;
2
3//If only 1 Parameter no () needed
4//Single line return is implicit
5//Single line no {} needed