views:

2846

answers:

3

Is there a 3rd party add-on/application or some way to perform object map dumping in script debugger for a JavaScript object?

Here is the situation... I have a method being called twice, and during each time something is different. I'm not sure what is different, but something is. So, if I could dump all the properties of window (or at least window.document) into a text editor, I could compare the state between the two calls with a simple file diff. Thoughts?

Thank you in advance.

-Jessy Houle

+8  A: 

Firebug + console.log(myObjectInstance)

Darin Dimitrov
+1  A: 
function mydump(arr,level) {
    var dumped_text = "";
    if(!level) level = 0;

    var level_padding = "";
    for(var j=0;j<level+1;j++) level_padding += "    ";

    if(typeof(arr) == 'object') {  
        for(var item in arr) {
            var value = arr[item];

            if(typeof(value) == 'object') { 
                dumped_text += level_padding + "'" + item + "' ...\n";
                dumped_text += dump(value,level+1);
            } else {
                dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
            }
        }
    } else { 
        dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
    }
    return dumped_text;
}
zhongshu
+1  A: 

for chrome/chromium

console.log(myObj)

or it's equivalent

console.debug(myObj)
kaznovac