(function(){
pm.view.someFunction(arg) {
arg is used here.
}
pm.view.otherFun(){
how can i pass the same arg here too
}
})();
how can i pass the same arg here in my other function. I heard that in closure we can access the variables which is above its context.
Closures mean that functions can use variables from their outer scope. Here’s an example:
The function returned by
test(strFunc) is a closure. It “closes” around the local variablestr.stris declared outside ofstrFunc, but since it’s in the same scope, it can access it.In your example, you just have two functions (one of which accepts an
argparameter), that are in the same scope.argis only insomeFunction‘s scope,otherFuncan’t access it unless it was passed as a parameter, or ifargwas declared outside of the functions, like howstris declared beforestrFuncis.