<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>几种方法</title>
<script>
function unique(data){
data = data || [];
var a = {};
len = data.length;
for (var i=0; i<len;i++){
var v = data[i];
if (typeof(a[v]) == 'undefined'){
a[v] = 1;
}
};
data.length=0;
for (var i in a){
data[data.length] = i;
}
return data;
}
function test(){
var arr = [9,1,3,8,7,7,6,6,5,7,8,8,7,4,3,1];
var arr1 = unique(arr);
alert(arr1.join(","));
}
test();
</script>
//方法二
<script language="网页特效">
function getnorepeat() {
return arguments[0].join('‖').match(/([^‖]+)(?!.*‖)/ig);
}
var tmparr = [1, 'a', 'ab', 'abc', 'd', 1.2, 'a+b', 'd', 'e', 5, 'www.111cn.net', 1, 'h', 'c', 'ab'];
var retarr = getnorepeat(tmparr);
alert(retarr);
</script>
//方法三
<script>
var s = "0,1,2,5,3,2,12,4,1,1,123450";
var stmp = (","+s.split(",").reverse().join(",")+",").replace(/,([^,]+)(?=,.*,,)/ig, '').split(",").reverse().join();
stmp = stmp.substr(1, stmp.length-2);
alert(stmp)
</script>
</head>
<body>
</body>
</html>