How to find unique records from two different array in jquery or javascript?

后端 未结 5 956
不思量自难忘°
不思量自难忘° 2021-01-05 15:16

I want to get unique values from two different arrays.

Two arrays are as below in JavaScript:



        
5条回答
  •  不知归路
    2021-01-05 15:51

    Like this:

    var a=['a','b','c','d','e']; //Use brackets
    var b=['a','d','e','c']
    
    var c = a.concat(b).sort();
    
    var uniques = {};
    
    for(var i=0; i

    Now uniquesArray contains only unique values. Hope this Helps

提交回复
热议问题