Copy Code code as follows:
<script type= "Text/javascript" >
<!--
var my={
STR: ',
deep:0,
Block: ',
Get_pre:function (N)
{
Pre= ';
for (i=0;i<n;i++)
{
Pre+=this.block;
}
return pre;
},
Show_obj:function (obj)
{
for (k in obj)
{
if (typeof (Obj[k])!= ' object ' && typeof (Obj[k])!= ' array ')
{
Pre=this.get_pre (This.deep);
this.str+=pre+k+ ' => ' +obj[k]+ ' \ n ';
}
else if (typeof (obj[k)) = = ' object ' && typeof (obj[k].length) = = ' undefined ')//if the object
{
Pre=this.get_pre (This.deep);
this.str+=pre+k+ ' =>object{\n ';
this.deep++;//begins recursion, depth +1
This.show_obj (Obj[k]);
Pre = This.get_pre (This.deep);
this.deep--;//recursive end a depth-1
This.str+=pre+ '}\n ';
}
else if (typeof (Obj[k]) = = ' object ' && typeof (Obj[k].length)!= ' undefined ')//If it is an array
{
Pre=this.get_pre (This.deep);
this.str+=pre+k+ ' =>array[\n ';
this.deep++;//the same object
This.show_obj (Obj[k]);
Pre = This.get_pre (This.deep);
this.deep--;//the same object
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 can use Console.log
IE,