Which return style in your opinion is „better”, more universal? For example, for this operation:
foo.filter(...).map(...).reduce(...)...
We have:
1st approach
const result = foo.filter(...).map(...).reduce(...);
return result;
2nd approach
return foo.filter(...).map(...).reduce(...);
If it comes to 1st approach I think it’s more readable if we have long code which result is stored in variable. But in 2nd option we don’t have extra variable, so we save memory a bit. Do you know any other cons nas pros? Which style should I use?
Aucun commentaire:
Enregistrer un commentaire