Remove the non-repeating array value method in two two-dimensional arrays

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.