Delete the same item in the array so that there are no duplicates in the array
The array's own method, splice (A, B), returns a new array after each use, so the recursive method must be used to remove the same items in the array, and if not, some items are ignored
For example, if recursion is not used, the output will be 1,2,3,4,5,6,7,1 it is obvious that the first and last items are the same and do not achieve the desired effect.
There is no problem with recursion, the output will be 1,2,3,4,5,6,7;
1 varARRZFS = [1,2,2,3,4,4,1,3,5,6,7,7,1,1,1,1,1];2(function()3 {4 for(vari = 0; i < arrzfs.length-1; i++)5 {6 for(varJ= i+1; J < Arrzfs.length; J + +)7 {8 if(Arrzfs[i] = =Arrzfs[j])9 {TenArrzfs.splice (j,1); OneArguments.callee ();//Call yourself A } - } - } the })(); -(function() - { - for(vari = 0; i < arrzfs.length; i++) + { - Cc.log (Arrzfs[i]); + } A})();
Make the array without duplicates by recursion