开发者

How can i access the functions from other JS files

(function () {    
    pm.view.functionName= function () {
        function nameFunction() {
          var something;
          return something;
        }    
        return win;
    };
})();

I am in another JS file and i want to call this nameFunction()... how can i do this. I tried...

开发者_Python百科
pm.view.functionName().nameFunction()

But i get an error called, cannot call function in the Object. How can i access the functions from other JS files.


The function nameFunction exists in the scope of the function functionName. You cannot access it from outside that function.

If you want to do so, you'll have to explicitly say so:

pm.view.functionName.nameFunction = function() {
    var something;
    return something;
};

You could then access it as pm.view.functionName.nameFunction().


nameFunction is local to pm.view.functionName and you cannot access it, just like you cannot access local variables. You can call nameFunction() only when being inside pm.view.functionName.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜