<script language="网页特效">
<!--
function each(list, fun){
for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
};var arr = [1,2,3,4,1,3]
var t
each(arr.sort(), function(o,i){
if(i>0 && o == t){ alert("相同的:" + o); }
alert(t)
t = o;
})//-->
</script>
方法三
function filterarray(str,array){ //此函数为过滤数组中重复的元素,并不允许插入空值,函数返回数组
var isnull = false;
if(str == "" || str == null || str == 'undefined'){
isnull = true;
}
var newnum = 0;
var newarray = [];
var num = array.length;
if(num == 0){
if(!isnull){
newarray[num] = str;
}
}else{
for(var m=0;m < num;m++){
if(str == array[m]){
break;
}else{
newarray[newnum++] = array[m];
}
}
if(!isnull){
newarray[newnum++] = str;
}
}
return newarray;
}
其它方法
<script>
alert("1,11,1.11,1111,111,11,1,1.11".match(/(d+(?:.d+)?)(?!.*,)/g))
</script>
<script>
alert("123450,0,1,2,5,3,2,12,4,1,1,123450".match(/(d+)(?!.*,(,|$))/ig))
</script>
<script>
alert("123450,0,1,2,5,3,2,12,4,1,1,123450".match(/(d+)(?!(?:,[^,]+)*,(?:,|$))/ig))
</script>