Skip to content

Instantly share code, notes, and snippets.

@M3kH
Last active December 23, 2015 09:39
Show Gist options
  • Save M3kH/6615963 to your computer and use it in GitHub Desktop.
Save M3kH/6615963 to your computer and use it in GitHub Desktop.
If I run inspector(window), I get all undefined, did you know why?
var inspector = function(obj){
var config = config || {},
html = '';
config.iter = function(e){
html = '<ul>';
if( typeof e === "function" ){
// setTimeout(function(){
try{
//Run some code here
var c = e;
e = c();
}catch(err){
//Handle errors here
// e ;
e = false;
// console.log(e);
// console.log(err);
}
// }, 25);
}
console.log(typeof e);
if( typeof e === "object" ){
// Object.keys(e).forEach(function(k) {
for(var k in e){
var type = typeof e[k];
if(type === "function" || type === "object" ){
html += '<li>'+k+' - ';
html += type;
html += '<br/> Properties:<br/>';
html += config.iter(e[k]);
html += '</li>';
}else{
html += '<li>'+k+' - ';
html += type;
html += '</li>';
}
};
// });
}else if( typeof e === "function" ){
html += '<li>';
html += typeof e;
html += '<br/> Properties:<br/>';
html += config.iter(e);
html += '</li>';
}else{
html += '<li>';
html += typeof e;
html += '</li>';
}
html += '</ul>';
return html;
};
return config.iter( obj );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment