I have arrays like
["key1",key2","key3"],["key4","key5","key6"],["key1","key7",key8","key9"]
In this "key1
" is common in first and third array.I want to identify this scenario.
EDIT This question is not a duplicate of Finding matches between multiple JavaScript Arrays.
I don't want to find the common elements of multiple arrays. I want to check whether atleast two arrays(any two) have atleast one common element.(This element need not be in other arrays in the set).
And I found the answer as well,Assume there won't be same elements inside an array.
Ans:
var containerKeys=[];
for(var i = 0;i < arraySet.length; i++ )
{
var arrValues = arraySet[i].value;
var keys = arrValues.split(",");
//checking whether different arrays have same keyword
var intersection=containerKeys.filter(function(n) {
return keys.indexOf(n) != -1;});
if(intersection.length>0){
//Show error that there are same elements.
return false;}
containerKeys=containerKeys.concat(keys);
}