intrader said:
I have a need to enumerate all functions in window object in order to
install intercepts. I have problem with the enumeration using the code
in the example
http://jsbin.com/acubo
Note: for now the code lists all elements in the window object.
I expect to see the global function 'fun' listed but I don't see it.
Why?
It is a bug of Internet Explorer. Your global property `fun`, declared as:
var fun = function(){
alert('...');
}
should be enumerable. In IE it is not. In IE, the global object is a
Host object. IE also uses a separate Variable object for the global
Variable object. The global Variable object is specified to be the same
as the global object.
That question, and problems related to the answer, comes up here about
every four months or so, dating back to I think I've seen around 2001 or
so (likely earlier). It is explained well enough here:
http://blogs.msdn.com/ericlippert/a...vation-objects-variable-objects-and-this.aspx
A good recent discussion that touched upon this issue, along with other
issues related to IE's global object is [[Delete]]'ing window properties
in IE in JScript.
http://groups.google.com/group/comp...read/thread/22e6b2d147f57ee5/dda4dee3390fa71a
And so after you've read all that, the test question:
How do you make `fun` enumerable in IE?
(It's not that hard, really).