function ergodic(obj,indentation){
var indent = " " 들여쓰기;
if(obj.constructor == 배열 || obj.constructor == 객체){
for(var p in obj){
if(obj[p].constructor = = 배열|| obj[p].constructor == 객체){
console.log(indent "[" p "] => " typeof(obj) "");
console.log(indent " {");
ergodic(obj[p], indent);
console.log(indent "}");
} else if (obj[p].constructor == String) {
console.log(indent "[" p "] => '" obj[p] "'");
} else {
console.log(indent "[" p "] => " obj[p] "");
}
}
}
}
function print_r(obj) {
console.log("{")
ergodic(obj, "");
console.log("}")
}
var stu = {'name':'Alan','grade':{'English': 120,'수학':130,'경쟁':{'NOI':'1등상'}}};
print_r(stu);