function findTheSame(array) {
let e = [];
let result = false
array.map((val1) => {
if (e.length == 0) {
e = val1;
} else {
e = e.filter((val2) => {
return val1.indexOf(val2) > -1;
})
}
})
if (e.length) {
result = array.every(it =>
e.every(its => it.indexOf(its) > -1)
)
}
return result ? e : []
}
找出数组中的相同元素
最新推荐文章于 2023-10-23 22:46:28 发布