How do i return true
if location.pathname
is found in of these strings is found in ES6?
const noActionMenuRoutes = [ '/master/employees', '/employees/dashboard', '/employees/requests', '/projects/myprojects', ]; const noActionMenus = () => { if (location.pathname.some(noActionMenuRoutes)) { return true; } else { return false; } };
Advertisement
Answer
You can use Javascript array includes
or indexOf
function.
if (noActionMenuRoutes.some(route => location.pathname.includes(route)))
if (noActionMenuRoutes.some(route => location.pathname.indexOf(route) !== -1)