Skip to content

Instantly share code, notes, and snippets.

@noel9999
Created July 8, 2014 10:50
Show Gist options
  • Save noel9999/df833096354591a240d1 to your computer and use it in GitHub Desktop.
Save noel9999/df833096354591a240d1 to your computer and use it in GitHub Desktop.
記錄一下自己寫的function,希望能做出像是ruby的inspect
function my_inspect(object,isExclusive){
isExclusive = typeof(isExclusive)!= "undefined" ? isExclusive : false
var result=[];
for(var member in object){
var type = typeof object[member];
if(isExclusive){
if (object.hasOwnProperty(member))
result.push(member+"["+type+"] : "+object[member]);
}
else{
result.push(member+"["+type+"] : "+object[member]);
}
}
return result.join('\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment