var abc = {
'a': 10,
'b': 10,
c: function() {
//like if I have many many functions in c
init_a();
multiple();
function init_a() {
abc.a = 30;
}
function multiple() {
alert(abc.a * abc.b);
}
function minus() {
alert(abc.a - abc.b);
}
return {
function myalert() {
var result = abc.a + abc.b;
alert(result);
}
}
},
d: function() {
abc.c.myalert(); // ??? error??
abc.c().myalert(); // ??? error?? **it run all functions in c but not just myalert, strange things happening...
}
}
abc.d();
什么是在函数d中调用'myalert()'函数的正确语法?如何调用函数内部函数?
没有一个,fu此外,你在某处丢失了一个右括号'}'。 – Jamiec
如果你不断改变你的问题中的代码,它会让你很难给出一个有用的答案。我会更新我的答案,希望您完成更新代码。 – AmericanUmlaut
没关系。当前版本包含语法错误 - 您将myalert函数定义为返回对象的属性,而不定义索引。 :( – AmericanUmlaut