In ES6/ES2015 arrow functions can be declared with or without brackets around the parameter.
ie:
var foo_1 = myVar => {
return myVar + 1;
}
or:
var foo_2 = (myVar) => {
return myVar + 2;
}
What I would like to know is: what is the difference (if any)?
There is no differences in your example.
You need parentheses if you
() => ...
(foo, bar) => ...
({foo}) => ...
(foo = 42) => ...
(...bar) => ...
In other words, whenever you do not have a single identifier-only parameter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.