gpt4 book ai didi

javascript - 在 jQuery 中调用同一对象上另一个函数中定义的函数

转载 作者:行者123 更新时间:2023-12-03 02:21:10 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com