复制代码 代码如下:
function ergodic(obj,indentation){
var indent = " " + indentation;
if(obj.constructor == Array || obj.constructor == Object){
for(var p in obj){
if(obj[p].constructor == Array|| obj[p].constructor == Object){
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':{'Chinese':120,'math':130,'competition':{'NOI':'First prize'}}};
print_r(stu);
function ergodic(obj,indentation){
var indent = " " + indentation;
if(obj.constructor == Array || obj.constructor == Object){
for(var p in obj){
if(obj[p].constructor == Array|| obj[p].constructor == Object){
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':{'Chinese':120,'math':130,'competition':{'NOI':'First prize'}}};
print_r(stu);
标签:
nodejs,print_r函数
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“用nodejs实现PHP的print_r函数代码”评论...