Skip to content

Instantly share code, notes, and snippets.

@trevorhreed
Created July 28, 2016 18:11
Show Gist options
  • Save trevorhreed/850df07e3fff407812e7ee42039a71f7 to your computer and use it in GitHub Desktop.
Save trevorhreed/850df07e3fff407812e7ee42039a71f7 to your computer and use it in GitHub Desktop.
function d(o, z){
var s = Array.isArray(o) ? '[\n' : '{\n',
a = '';
z = z || 0;
for(var i=0; i < z; i++) a += '\t';
for(var p in o){
var v = o[p],
t = 'unknown';
if(Array.isArray(v)){
t = 'array';
}else{
t = typeof v;
}
if(t == 'object' || t == 'array') v = d(v, z + 1);
if(t == 'function') v = '...';
s += a + '\t' + p + '(' + t + '): ' + v + '\n';
}
return s + a + (Array.isArray(o) ? ']\n' : '}\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment