I am not sure if this is possible (in fact I\'m struggling to work out what to google for) but here it goes:
I have a function
const test = () => {
You can do this if you first check the type of the variable, in particular you will check if its a Function:
function isFunc(functionToCheck) {
return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
};
So if this is true, then your variable is infact a function and you can return the stuff you need from it:
const isItAFunction = somevariable;
if(isFunc(isItAFunction)) {
// return your string
} else {
// do something else
}