1 <!DOCTYPE HTML> 2
1. First, we have two arrays. One in array A has a value. The other is array B. The other is array B.
The idea is as follows: when we put the array in array a into array B one by one, if we find that there is the same number as the number in array B, we will not put the items in array a de-duplicated like this.
Line 20 of the Code: declare an array A (there are many repeated items in array)
Line 21 of the Code: declare an array B (B is an empty array to display the de-duplicated Effect of array)
For (VAR I = 0; I <. length; I ++) // traverse array a 24 {25 if (fun (A [I]) // execute a function this function is fun () in addition, each value in array a is passed to the fun function. In this function, 26 {27 continue; // If the returned value is true, the function executes the continue (that is, it does not continue to be put into array B) 28} 29 else {30 B. push (A [I]); // if the return value of the function is false, insert a [I] 31 to array B}
Function fun (AAA) {// fun () Is the function 33 for (var ii = 0; II <B. length; II ++) // first, we need to traverse the array B, which is also an empty array so that we can know whether the values in array a are repeated 34 {35 if (B [II] = aaa) // if the value of B [II] is found to be AAA (AAA is the input parameter. this parameter is the value of a [I] In if) if it is equal to, true is returned to the IF parameter so that the contine in the previous parameter is executed, that is, the value is no longer in the B array. If B [II] is not equal to AAA during traversal execute return false to let the previous if execute the else {} operation, that is, continue to input the value 36 {37 return true to the B array; 38} 39} 40 return false; 41 42}