This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
hi, The for(var in obj) loop can enumerate most (if not all) properties of a given obj, but how to differentiate whixh are the fields and which are the methods. Are there predefined functions that can do that?
Well, it depends on a browser. I tried your code in IE6 and firefox.
if you run the code you posted in IE, methods wil not be returned, but event handlers are. For them typeof(window.document[property]) will be "object" if they are not set and "function" if they are set. You can filter them out since they always start with "on".
In firefox, event handlers will not be returned, but methods are. typeof(window.document[property]) will be "function" for those methods. [ December 07, 2005: Message edited by: Yuriy Fuksenko ]