this code is not very understood, ask the great god for help under the popular science. The main reason is that the code in the 2 for loops is a little unintelligible, so if it is convenient to add comments to explain it.
var array = ["c", "a", "z", "a", "x", "a"];
function clear() {
var o = {};//
for(var i = 0; i < array.length; iPP) {
var item = array[i];//
if(o[item]) {
o[item]PP;
} else {
o[item] = 1;
}
}//end for
var tmpArray = [];
for(var key in o) {
if(o[key] == 1) {
tmpArray.push(key);
} else {
if(tmpArray.indexOf(key) == -1) {
tmpArray.push(key);
}
}
}//end for
return tmpArray;
}//end function
console.log(clear(array));