判断数组 arr 中是否有重复的元素,一个巧妙的做法: if (arr.length > new Set(arr).size) { console.log('有重复元素')} else { console.log('无重复元素')}