开发者

arguments.callee.caller... how to get 'this' reference of a caller object?

I have a configuration object which may c开发者_运维百科ontainer scope property and may not and I pass it to my function. This function creates some callback functions and applies 'scope' property to them. I want to force this function to provide the scope even if it is not actually specified - to get 'this' reference of a caller, something like this:

function someFunc (config)
{
  var scope = config.scope ? config.scope : arguments.callee.caller... (?);
  config.preAction.apply(scope);
}

Is it actually possible?


Just as you assumed in your comment, the answer is that it is impossible. JavaScript is simply not introspective enough.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜