[英]JS : Calling a function within a named function
I am trying to get access to the named function create
from the testingSounder
function. 我试图访问来自
testingSounder
函数create
的命名函数。 How would I go about this when they are nested named functions like this? 当它们嵌套这样的命名函数时,我将如何处理?
loadSounder: function() {
var mentForm = (function (appId, locId) {
var create = function() {
console.log("CREATING")
}
})
},
testingSounder: function() {
//How can I run the create function from loadSounder?
}
You need to return both functions: 您需要返回两个函数:
loadSounder: function() {
var mentForm = function (appId, locId) {
var create = function() {
console.log("CREATING")
};
return create;
};
return mentForm;
},
testingSounder: function() {
this.loadSounder()("app", "loc")();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.