代码
忽略元素type
function deleteMulti(arr) {
let obj = {},
res = [],
current;
for (let i = 0; i < arr.length; i++) {
current = arr[i];
if (!obj[current]) {
obj[current] = current;
res.push(current);
}
}
return res;
}
如果type不同则不删除
function deleteMulti(arr) {
let obj = {},
res = [],
type,
current;
for (let i = 0; i < arr.length; i++) {
current = arr[i];
type = typeof current;
if (!obj[type]) {
obj[current] = current;
res.push(current);
}
}
return res;
}