js callee.caller as object instead of function
I have an OOP project in JS and I want to find the owner object of a the caller.callee
Example: myObj.someFunc is called by yourObj.someFunc I want to get a reference to yourO开发者_JAVA技巧bj from within myObj.someFunc and I need to do this without passing a reference to yourObj as a parameter.
Something like callee.caller.object would be nice, but of course, doesn't exist.
You're looking for the this
binding of the calling function -- unfortunately, the ECMAScript standard provides no way to obtain this.
Further, arguments.callee.caller
has also been removed in ECMAScript 5, so you should no longer rely on using it.
精彩评论