var object = {
a: 1,
b: 2,
c: {
d: 3
}
};
Object.defineProperty(Object.prototype, 'dump', {
value : function() {
var output = [];
for (var i in this) {
if (this.hasOwnProperty(i))
{
var key = i + "=";
var value = this[i];
output.push(key += {
"[object Object]" : value.dump(),
"[string Object]" : "\"" + value + "\""
}[Object.prototype.toString.call(value)] || value);
}
}
return "{" + output.join() + "}";
},
configurable: 1,
writable : 0,
enumerable: 0
});
alert(object.dump());