In JavaScript, you can access functional properties functions, for example caller. (In fact, I don’t even know if the “functional property” is the right word.)
For instance:
func0 = function() {
console.log(typeof func0.caller)
}
func1 = func0
func1()
var o = { func2: func0, func3: function(){ console.log(typeof o.func3.caller) } }
o.func2()
o.func3()
As you can see, before adding .caller, you must specify the name of the function. But if the function is anonymous or for some reason I don’t want to use the name (maybe I plan to rename fucntion in the future): can I access the caller?
source
share