开发者

How can i access the functions from other JS files

开发者 https://www.devze.com 2023-03-30 19:04 出处:网络
(function () { pm.view.functionName= function () { function nameFunction() { var something; return something;
(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

精彩评论

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