<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
var arr = [1,2,3,4,4,5,6,7,2,1]
function unique(arr) {
var arr2 = []
for(var i in arr) {
if(arr2.indexOf(arr[i]) == -1) {
arr2.push(arr[i])
}
}
return arr2
}
console.log(unique(arr))
</script>
</body>
</html>
至此。