复制代码代码如下:
Функция эргодика (obj, adpration) {
var addent = "" + adpration;
if (obj.constructor == массив || obj.constructor == Object) {
для (var p in obj) {
if (obj [p] .constructor == Array || obj [p] .constructor == Object) {
console.log (odent+"["+p+"] =>"+typeof (obj)+"");
console.log (odent + "{");
эргодик (obj [p], отступ);
console.log (odent + "}");
} else if (obj [p] .constructor == string) {
console.log (odent+"["+p+"] => '"+obj [p]+"'");
} еще {
console.log (odent+"["+p+"] =>"+obj [p]+"");
}
}
}
}
функция print_r (obj) {
console.log ("{")
эргодик (obj, "");
console.log ("}")
}
var stu = {'name': 'alan', 'grade': {'китайский': 120, 'математика': 130, 'конкуренция': {'noi': 'first prize'}}};
print_r (stu);