In ES6, a new form of arrow function was added, which is actually a function;
Here's a brief look at :
Above we defined a function in the form of an es6 arrow function;
let is equivalent to the previous var, used to define variables, but let has the nature of block-level scope;
func represents the function name;
The equal sign = is followed by our parameters;
After the arrow is our return value;
Compare and see :
The arrow function above defaults to one parameter. What if we have multiple parameters?
It's as simple as enclosing the parameters in parentheses:
The return of the above function is the case when there is only one statement. According to the above writing method, it will return by default, but there is rarely only one statement in the function.
Let's see how to write it in the case of multiple statements?
First of all, multiple statements need to be added after the arrow function { Statements are written in it }
Second, the return value needs to be written explicitly, that is, return + result;
After understanding the above parts, you can basically use arrow functions. For more details, please refer to the documentation;