var print = function(element) { var str = ""; for (var prop in element){ if (typeof(element[prop]) == "string") { str += prop + ": " + element[prop] + "<br/>"; } else if (typeof(element[prop]) == "function") { str += prop + ": (function)<br/>"; } else { str += prop + ": { <br/>" + print(element[prop]) + "}"; } } return str; }