how to access the anonymous scope?

3 views
Skip to first unread message

Johnny

unread,
Aug 17, 2008, 10:07:52 PM8/17/08
to Chiron JavaScript
this is my test(not with modules.js):

<script>
var sameid = 5;
function sameid ()
{
alert("function sameid");
}
alert(sameid);// 5
sameid();
<script>

first: the var and function which have the "sameid" will cause the
"sameid function" out of work,the var sameid seem have the higher
priority than function sameid. how to avoid this?
-------------------



<script>

function gscope ()
{
alert("gscope");
}
this["gscope"]();

var c = {};
with(c)
{
(
function ()
{
function innerscope1 ()
{
alert("innerscope1");
}
//eval("innerscope1()");
this["innerscope1"]();
}
)();
}

var b = {};
with(b)
{
(
function ()
{
function innerscope ()
{
alert("innerscope");
}
//eval("innerscope()");
this["innerscope"]();
}
).call(b)
}
this["innerscope"]();
<script>

it seems that the innerscope () isn't in the global scope also in the
b scope whatever i replace "this" with b or not.
so ,does it in the anonymous scope? but how can i access the anonymous
scope? does the eval(innername) is the only approach?

does it the "inconsistent point" whith the global scope? because i can
access gscope () use "this["gscope"]();"

i know it is some times boring,i just found it when i want do some
kind of reflection on functions;

Kris Kowal

unread,
Aug 17, 2008, 10:49:52 PM8/17/08
to chir...@googlegroups.com
Let's take this offlist since it's not on topic.

Johnny

unread,
Aug 18, 2008, 11:14:18 AM8/18/08
to Chiron JavaScript
ok,thanks.
> > kind of reflection on functions;- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages