R
runsun pan
This has been puzzling me for a long time.
Lets defined a global variable (not within any function) :
var fff = function(){}
This creates a global object that we can access via:
alert(fff)
or
window['fff']
We can even check this:
alert( 'fff' in window )
that gives us *true*.
However, if we try to locate this "fff" through a for loop:
for (var k in window) { blah blah blah }
It doesn't see "fff". This happens only in IE but not in Firefox.
Can anyone explain this, or better yet, show me how to do a correct
loop ?
Lets defined a global variable (not within any function) :
var fff = function(){}
This creates a global object that we can access via:
alert(fff)
or
window['fff']
We can even check this:
alert( 'fff' in window )
that gives us *true*.
However, if we try to locate this "fff" through a for loop:
for (var k in window) { blah blah blah }
It doesn't see "fff". This happens only in IE but not in Firefox.
Can anyone explain this, or better yet, show me how to do a correct
loop ?