1 vararr1=[2[1,2,3,4,5],3[1,2,3,4,5],4[12,3,4],5[6,7,8],6[32,2]7 ];8 varArr2=[9[1,2,3,4,5],Ten[6,7,8], One[6,7,8], A[15,16] - ]; -Console.log (Fillterarr (ARR1,ARR2));//[" 12,3,4"] ["15,16"] ["32,2"]
Method:
1 functionFillterarr (arr1,arr2) {2 3 vararr11=stringto (arr1);4 varArr22=stringto (ARR2);5 functionstringto (AR) {6 varArr=[];7 for(vari=0;i<ar.length;i++){8 Arr.push (ar[i].tostring ());9 }Ten returnarr; One } A functionUnique (arr) { - //traverse arr to place elements into the TMP array (not present) - varTMP =NewArray (); the for(varIincharr) { - //The element does not exist inside TMP to allow append - if(Tmp.indexof (Arr[i]) ==-1){ - Tmp.push (Arr[i]); + } - } + returntmp; A } at functionGetrepeatfwxmmc (ary1) { - varary = Ary1.sort ();//Array Sorting - varCffwxmsary =NewArray (); - //all repeating elements are added into the new array - for(vari=0;i<ary.length;i++){ - if(ary[i]==ary[i+1]){ in Cffwxmsary.push (Ary[i]); - } to } + varresult =[], isrepeated; - //element deduplication for repeating element arrays the for(vark = 0; K < Cffwxmsary.length; k++) { *isrepeated =false; $ for(varj = 0;j < Result.length; J + +) {Panax Notoginseng if(Cffwxmsary[k] = =Result[j]) { -isrepeated =true; Break; the } + } A if(!isrepeated) { the Result.push (Cffwxmsary[k]); + } - } $ returnresult; $ } - vararr1111=Unique (ARR11); - varArr2222=Unique (ARR22); the - vararr01=Arr1111.concat (arr2222);Wuyi //Duplicate Array Values the varArr02=Getrepeatfwxmmc (ARR01); - functionGetData (A, b) { Wu - varC=[]; About vararr00=[]; $ for(varIincha) { -c[a[i]]=A[i]; - } - for(varIinchb) { A if(C[b[i]]) { + DeleteC[b[i]]; the}Else{ -c[b[i]]=B[i]; $ } the } the for(varIinchc) { the Arr00.push (C[i].split ()) the } - returnarr00; in } the the returnGetData (ARR01,ARR02); About}
Remove the non-repeating array value method in two two-dimensional arrays