View Full Version : Detecting unknown objects & properties?

08-03-2007, 12:08 PM
Is there a way to detect unknown object and their properties, without knowing the object/property names beforehand?

I'm interested in ways to get the code to describe itself, so I can do some research without proper documentation.

Are there set commands for stuff like this or some clever techniques, is it even possible?


08-03-2007, 02:57 PM
Yep, you can do something like this:

function showProps(obj){
var message="";
for(prop in obj){
message += obj.name+".";
message += prop+"="+obj[prop]+"\n";

Though you may not like what you find!

08-03-2007, 06:39 PM
Thanks a lot, with a few slight mod's that was exactly what I was looking for!

Why did you think I might not like it?

08-03-2007, 08:38 PM
I seem to remember that looking at certain html objects you end up with tons of properties, most of which are completely irrelevant to what I was after. Perhaps you're after them all, if so great!