I have the following piece of code:
function initValidation()
{
// irrelevant code here
function validate(_block){
// code here
}
}
Is there any way I can call the validate()
function outside the initValidation()
function? I've tried calling validate()
but I think it's only visible inside the parent function.
Hope that you are looking for something like this
This will work.
Hope this addresses your problem.
This invocation will return function statement, which is function validate. So you can invoke directly after the first invocation.
I know this is an old post but if you wish to create a set of instances that you wish to work with that reuse the code you could do something like this:
You can call
validate
from withininitValidation
. Like this.validate
is not visible to anything outside ofinitValidation
because of its scope.Edit: Here's my suggestion of a solution.
All of your functions will be hidden to anything outside the function wrapper but can all see each other.
Should work.