1

    1. //简单数组
    2. function hasDuplicates(a) {
    3. return _.uniq(a).length !== a.length;
    4. }
    5. var a = [1,2,1,3,4,5];
    6. var b = [1,2,3,4,5,6];
    7. document.write(hasDuplicates(a), ',',hasDuplicates(b));
    1. //对象数组
    2. var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
    3. let arr= _.uniqWith(objects, (item1,item2)=>{
    4. retutn item1.x==item2.x&&item1.y==item2.y
    5. });
    6. console.log(arr.length,objects.length)