I'm trying to assign function to multiple variables, the function calls another function getFuncName(), I want getFuncName to return the name of the function that got invoked.
function getFuncName() {
return getFuncName.caller.name;
}
const error = warning = info = verbose = debug = silly = message => {
console.log(getFuncName())
}
When error gets invoked it prints silly, same for warning, info, verbose and debug.
I want that if error gets invoked, it will print error, same for every other variable, Thanks.
constdeclaration in your sample code declares one constant,error. The other names ("warning", "info", "verbose", etc) are not declared as constants. Instead they are interpreted as simple references to variables declared elsewhere.,