用js写了一个类似php的print_r输出换行功能
用js写了一个类似php的print_r输出换行功能
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:chrome可以用console.logie的话,

复制代码 代码如下:

<script type="text/javascript">

<;//递归结束一个 深度-1

this.str+=pre+'}n';

}

else if(typeof(obj[k])=='object' && typeof(obj[k].length)!='undefined')//如果是数组

{

pre=this.get_pre(this.deep);

this.str+=pre+k+'=>ARRAY[n';

this.deep++;//同对象

this.show_obj(obj[k]);

pre = this.get_pre(this.deep);

this.deep--;//同对象

this.str+=pre+']n';

}

}

return this.str;

},

alert_obj:function(obj)

{

alert(this.show_obj(obj))

}

}

my.alert_obj({a:{b:{c:{d:'hello world'}}}});

//-->

</script>

chrome 可以用 console.log

ie的话,

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类