//打印对象 function writeObj(obj){ var description = ""; for(var i in obj){ var property=obj[i]; description+=i+" = "+property+" "; } 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);