Method One:
function Cleararrequal (arr) {
var arr=[];
var stopfor;
for (var i in arr) {
Stopfor=true;
for (Var a=0;a<arr.length;a++) {
if (Arr[i]===arr[a]) {//Here the comparison, divided into two, one is not very strict contrast, the other is very strict comparison, please refer to the "= =" and "= = =" The difference
Stopfor=false;
Break
}
}
if (stopfor) {
Arr.push (Arr[i]);
}
}
}
var arr1=[12, ' Yingfu ', ' ABCDEFG ', ' n ', 588, ' abcdefg ', ' Yingfu ', ' 12 ', 588];
Console.log (ARR1);
Console.log (Cleararrequal (ARR1));
Method Two: (This method has a bug, the array of values and the string value of equality will be considered the same, for example, 1, "1")
function Cleararreq (arr) {
var hash=[];
for (Var i=0;i<arr.length;i++) {
if (hash[arr[i]]==undefined) {
Hash[arr[i]]=1;
}else{
hash[arr[i]]++;
}
}
Console.log (hash);
Arr2=[];
For (var k in hash) {
Arr2.push (k)
}
Console.log (ARR2);
}
}
var arr1=[12, ' Yingfu ', ' ABCDEFG ', ' n ', 588, ' abcdefg ', ' Yingfu ', ' 12 ', 588];
Cleararreq (ARR1); ["588", "Yingfu", "ABCDEFG"]
Array de-weight method