一、对于数组
var arr=['姚明','易建联','张继科'];
 
		 
		$.each(arr,function(index,value){
			document.write(index+"="+value+"</br>");
			
		});
		
		
      for(var i in arr){
		  document.write(i+"</br>");   //获得数组下标
		  document.write(arr[i]+"</br>");
	  }
二、对于对象
var object={name:"姚明",sex:'man'};
var o2={name="姚明",sex='man'};这么定义对象是错误的
$.each(o,function(key,value){
			document.write(key+"="+value+"</br>");
			
		});		
 for(var i in o){
		  
		  document.write(i+"</br>");   // 获得键值对的键key
		  document.write(o[i]+"</br>");
	  }
注:for()遍历对象或者数组其格式一样  document.write(arr[i]+"</br>");  document.write(o[i]+"</br>");
                    
                
                
            
        
浙公网安备 33010602011771号