题解 | #查找重复元素#
查找重复元素
https://www.nowcoder.com/practice/871a468deecf453589ea261835d6b78b
let obj = {}
let array = []
for (let i = 0; i < arr.length; i++) {
if (!obj[arr[i]]) {
obj[arr[i]] = true
} else if (array.indexOf(arr[i]) == -1) {
array.push(arr[i])
}
}
return array