JS:在命名函数内调用函数

时间:2019-04-17 04:41:13

标签: javascript function object

我正在尝试从create函数访问命名函数testingSounder。当它们嵌套这样的命名函数时,我将如何处理?

loadSounder: function() {
     var mentForm = (function (appId, locId) {
          var create = function() {
              console.log("CREATING")

          }
     })
},

testingSounder: function() {

     //How can I run the create function from loadSounder?
}

1 个答案:

答案 0 :(得分:1)

您需要返回两个函数:

loadSounder: function() {
     var mentForm = function (appId, locId) {
          var create = function() {
              console.log("CREATING")
          };
          return create;
     };
     return mentForm;
},

testingSounder: function() {
    this.loadSounder()("app", "loc")();
}