How can I debug a variable of type [Function]?
Some functions are defined in variables. And I want to debug what function is installed there? However, this function cannot be changed. In this situation, how should I debug?
var something = returnfunc(); //returnfunc() return function type object
console.log(something);
[Function]
+3
source to share
3 answers
I think you are asking how to define the function to return returnfunc
. If you are using an anonymous function, it is harder to debug because the function is not identified by name:
function returnfunc () {
return function () {
return 'I am an anonymous function'
}
}
var fn = returnfunc() // [Function]
But you can just give the function a name:
function returnfunc () {
return function foo () {
return 'I am a named function'
}
}
var fn = returnfunc() // [Function: foo]
0
source to share