I have the following code with a recursive function which I would like to transform to recursive arrow function:
const hasAccess = menuSections.some(function s(x) {
if (x.link === route.routeConfig.path) {
return true;
}
if (x.sections) {
return (x.sections.some(s));
}
return false;
});
Any idea on how to do it?
this,argumentsor anything else that would be handled differently by an arrow function. It does use its own name to recurse, and arrow functions are anonymous. For your problem a function expression has benefits over an arrow function but an arrow function has no benefits at all over a function expression.