好吧,鉴于以下Javascript
我不想修改的代码:
(function () {
function iWantToCallThis(){
// Do some stuff
}
window.SomeObject = {
theirfunc = function(){
// Do some stuff
},
otherFuncIDontWantToCall = function(){
// This works, but don't want to call this function.
iWantToCallThis();
// does other stuff
}
}
}());
我怎样才能iWantToCallThis()
像这样通过 SomeObject 的范围进行访问:
window.SomeObject.theirfunc = (function (func){
iWantToCallThis();
func.apply(this, arguments);
} (win.SomeObject.theirfunc));
即使我认为该功能在其原始范围内 - 从技术上讲 - 运行,我也无权访问iWantToCallThis()
. 有没有办法在不编辑原始源代码的情况下访问该功能?
谢谢!