fonction ergodique(obj,indentation){
var indent = " " indentation;
if(obj.constructor == Array || obj.constructor == Object){
for(var p in obj){
if(obj[p].constructor = = Tableau|| obj[p].constructor == Objet){
console.log(indent "[" p "] => " typeof(obj) "");
console.log(indent " {");
ergodique(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("{")
ergodique(obj, "");
console.log("}")
}
var stu = {'name':'Alan','grade':{'Chinese': 120,'math':130,'concours':{'NOI':'Premier prix'}}};
print_r(stu);