I\'m learning ES6 fat arrow functions. What is the correct way to change this code, so as to be able to put another line, even const a = 100;
in the place indic
If you want to convert the following method into having more lines:
{
filter: appointment => true
}
You have to add curly braces and a return
statement:
{
filter: appointment => {
// ... add your other lines here
return true;
}
}
filter: appointment => true,
...
is (and parentheses aren't needed around true
) a shortcut for
filter: appointment => {
return true;
},
...
which is a shortcut for
filter: function (appointment) {
return true;
}.bind(this),
...
Any amount of lines can be added before return
statement.