Skip to content

Instantly share code, notes, and snippets.

@trevorhreed
Last active December 28, 2015 09:19
Show Gist options
  • Save trevorhreed/7478307 to your computer and use it in GitHub Desktop.
Save trevorhreed/7478307 to your computer and use it in GitHub Desktop.
function dir(o, d){
var s = '';
var t = d || '';
console.log('|' + t + '|');
for(var p in o){
if(typeof o[p] == 'object'){
l = (Object.prototype.toString.call(o[p]) === '[object Array]') ? '[array]' : '[object]';
s += t + p + ': ' + l + '\n';
s += dir(o[p], t + ' ')
}else{
s += t + p + ': ' + o[p] + '\n';
}
}
if(!d){
alert(s);
}
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment