var myfunction = function (obj1){
init = function(){
///object operation
func1();
}
func1 = function(){
some operation
}
}
在上面的代码中,有一个名为 func1 的函数,它定义在 myfunction 中,对某个对象进行操作。在myfunction()内部,调用func1()来改变对象,我想直接调用这个对象。
最佳答案
var func1 = ''
var myfunction = function(obj1) {
func1 = function(p, v) {
return p + ' - ' + v;
}
var init = function(data) {
return func1(obj1, data);
}
return init;
}
var d = myfunction('Hellow');
var result = d('world')
console.log('Inside call ', result)
console.log('Dirct call', func1('Hellow', 'World'))
关于javascript - 在 jQuery 中调用同一对象上另一个函数中定义的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49149461/