erp-el-element/utils/Set.js

14 lines
399 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export function hasDuplicate(arr) {
// 将数组转换为Set
var set = new Set(arr)
console.log(set)
const Array = arr.filter((item, index) => arr.indexOf(item) !== index)
console.log(Array)
// 如果Set的长度小于数组的长度说明有重复的值
if (set.size < arr.length) {
return { arr: Array, status: true }
} else {
return { arr: Array, status: false }
}
}