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
.
精彩评论