Calling a function defined inside another function
Posted: February 2nd, 2018, 8:47 pm
I am trying to call a function that is defined inside another function. So say I have this:
Is there any way to call test() without explicitly calling it inside of myFunc()?
For instance, I'd like to be able to call it like this:
But in any case, I always get an error saying test() is undefined. Does anyone know how to accomplish this?
My end goal is to expose a function within my script so that external scripts can access it directly.
Thanks
Code: Select all
function myFunc()
{
function test()
{
alert("test');
}
}
For instance, I'd like to be able to call it like this:
Code: Select all
myFunc().test()
or
myFunc.test()
But in any case, I always get an error saying test() is undefined. Does anyone know how to accomplish this?
My end goal is to expose a function within my script so that external scripts can access it directly.
Thanks