//打印对象 function writeObj(obj){ var description = ""; for(var i in obj){ var property=obj[i]; description+=i+" = "+property+"\n"; } alert(description); } //打印数组 function print_array(arr){ for(var key in arr){ if(typeof(arr[key])=='array'||typeof(arr[key])=='object'){//递归调用 print_array(arr[key]); }else{ document.write(key + ' = ' + arr[key] + '<br>'); } } } var a=new Array(0,1,2,3,4,new Array('dog','cat','mao')); print_array(a);
js打印对象,打印数组函数
本文地址:http://wuheng.net/blog_76.html 转载请注明出处