I would like to variably assign a name to a new function, is this possible?
function returnFunctionWithName(str){
return function(){
return srt
}
}
var x = returnFunctionWithName("hello")
console.log(x) // => [Function]
What I want is something like this: (this doesn't work)
function returnFunctionWithName(str){
return function [str](){
return srt
}
}
var x = returnFunctionWithName("hello")
console.log(x) // => [Function: hello]
Just tried this too with no effect:
function returnFunctionWithName(str){
var x = function(){
return str
}
x.name = str
return x
}
var x = returnFunctionWithName("hello")
console.log(x) // => [Function: hello]