Created
October 18, 2013 14:04
-
-
Save khebbie/7042013 to your computer and use it in GitHub Desktop.
Dump all properties of an object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function simpleObjInspect(oObj, key, tabLvl) | |
{ | |
key = key || ""; | |
tabLvl = tabLvl || 1; | |
var tabs = ""; | |
for(var i = 1; i < tabLvl; i++){ | |
tabs += "\t"; | |
} | |
var keyTypeStr = " (" + typeof key + ")"; | |
if (tabLvl == 1) { | |
keyTypeStr = "(self)"; | |
} | |
var s = tabs + key + keyTypeStr + " : "; | |
if (typeof oObj == "object" && oObj !== null) { | |
s += typeof oObj + "\n"; | |
for (var k in oObj) { | |
if (oObj.hasOwnProperty(k)) { | |
s += simpleObjInspect(oObj[k], k, tabLvl + 1); | |
} | |
} | |
} else { | |
s += "" + oObj + " (" + typeof oObj + ") \n"; | |
} | |
return s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment