访问其他作用域中的函数,同时具有对同级函数的访问权限
Access function in other scope, while having acces to a sibling
我正在尝试更改一个外部库(ember数据)。但是我无法访问我想要更改的函数的范围。
我做了一个解释和一个非常简单的用例:http://jsfiddle.net/yr5Lmzyk/3/
// =========== External libary (cannot be changed)---------------------------
var ex = {};
(function (__exp__){
ob = {
prefix: 'object-prefix',
say: function(word){
return this.prefix + "|" + abcd(word);
}
};
function abcd(a){
return a + "|function-postfix";
}
__exp__.ob = ob;
}(ex));
var ob = ex.ob;
// ================= Available/ ajustable code ---------------------
// i want to change the working of the abcd function.
// in the real case abcd is used in many functions of ob, but i only want to change that function.
$("#content").html(ob.say("call-parameter"));
上半部分是"外部"库,我无法更改。下面是我的代码,我可以访问它。当我在ob对象上运行say方法时,它使用函数abcd。我想改变这个功能的工作方式。
如何访问此范围,以更改abcd函数?
abcd
函数是其private您不能更改它,您可以更改say
函数,但您无法访问尚未公开的
相关文章:
- javascript函数访问ios本机功能
- 从嵌套函数访问函数属性
- 将typescript函数访问到angular中
- 全局变量只能由第一个函数访问
- Javascript从匿名函数访问外部对象属性
- UI网格:如何从自定义函数访问MODEL_COL_FIELD
- 在jQuery中,我如何从$.ajax回调函数访问$(this)
- 如何在JavaScript中停止从特定函数访问某些函数和变量
- 从jQuery.ech()函数访问外部作用域
- Angular2/Typescript:从链接可观察函数访问实例变量
- 局部变量仍可通过函数访问
- 从Kendo中的columns.filterable.cell.template函数访问列字段名
- 可以't从JS函数访问combodate
- 如何在javascript中将变量从一个函数访问到另一个函数
- jQuery从PHP函数访问Ajax响应
- 如何从json函数访问javascript中的基类变量
- 在OPP JS中,您可以从构造函数访问原型函数内部声明的方法
- Javascript 使用函数访问其他类
- 从 JavaScript 中的私有函数访问公共函数
- 为什么我无法从茉莉花中的 javascript 函数访问全局变量