After checking out the Stack Overflow link here, I came across a suggested solution:
var controllerName = '@ViewContext.RouteData.Values["Controller"].ToString()';
However, despite implementing this code in my JavaScript file, it does not yield the expected result. Instead of returning the actual controller name, it simply displays the string value '@ViewContext.RouteData.Values["Controller"].ToString()', without computing the appropriate name.