不用array api
1.双重for循环
2.hashmap方式,需要考虑a[1] == a['1']的情况
function uniq(array){
var temp = {}, r = [], len = array.length, val, type;
for (var i = 0; i < len; i++) {
val = array[i];
type = typeof val;
if (!temp[val]) {
temp[val] = [type];
r.push(val);
} else if (temp[val].indexOf(type) < 0) {
temp[val].push(type);
r.push(val);
}
}
return r;
}
利用array api
1.排序后遍历推入[]
2.set
3.filter(indexof)
4.reduce(indexof)
5.遍历推入(indexof)