日期:2014-05-16  浏览次数:20435 次

去掉JS数组中重复的元素
<SCRIPT LANGUAGE="JavaScript">
<!--
//(2)将所有相同的option内容去掉
function test(){
	var array=["1","2","2","3","cc","cc"];
	var data={};	
	var desiredArr=new Array();  
	for(var i=0;i<array.length;i++){  
		data[array[i]]=array[i];  
	} 
	
	for(var pro in data){  
	 desiredArr.push(data[pro]);
	} 

	for(var tt in desiredArr){
	alert(desiredArr[tt]);
		}
}
test();
//-->
</SCRIPT>

?