<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>数组去重</title>
</head>
<body>
<script type="text/javascript">
var arr = [41,23,1,2,5,6,4,1,2,8,9,9,4,6,5,7,9,7,23,41];
function fun(arr) {
var res = [arr[0]];
for(var i = 1; i < arr.length; i++) {
var repeat = false;
for(var j = 0; j < res.length; j++) {
if(arr[i] == res[j]) {
repeat = true;
break;
}
}
if(!repeat) {
res.push(arr[i]);
}
}
return res;
}
fun(arr);
console.log(fun(arr))
</script>
</body>
</html>