复制代码 代码如下:
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实现PHP的print_r函数代码的全部内容,更多相关用nodejs实现PHP内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复