Reputation: 143
I have a complex code.this is its sample.i can not change structure. how can i call e()
in f()
?
a=function b()
{
var c,d;
c=function()
{
function e()
{
...
}
...
}
d=function()
{
function f()
{
//i need e() here
}
....
}
}
Upvotes: 0
Views: 66
Reputation: 43228
You can't as those are local functions within different scopes and are not accessible from each other. If you need to call e()
from inside f()
's scope, then e()
shouldn't be defined within c()
's scope, but within b()
, where it will be visible in f()
's scope.
Upvotes: 2
Reputation: 8368
You can't. That's the whole point of scoping.
You can, however, make the variable e
available to the parent scope by declaring it outside the function c
.
a = function b() {
var c, d, e;
c = function () {
e = function () {
...
};
...
};
d = function () {
function f() {
e();
}
...
};
};
Upvotes: 1