JS Object Iterator

Extremely handy when you’re dealing with an Object and have no idea what it’s methods or properties are. ESPECIALLY when there’s no documentation and you get an alert saying [Object] or whatever.

function deconstruct(what){
    obj = eval(what);
    var temp = "";
    for (x in obj)
            temp += x + ": " + obj[x] + "\n";
    alert (temp);
}

I wish I remember the source for this because it has to be one of the handiest functions ever.

Leave a Reply