Way one: Normal mode
1. Build a new temporary array to store the results
Each time an element is removed from the original array in the 2.for loop, the loop is compared with the temporary array.
3. If the element is not in the temporary array, it is stored in a temporary array
Mode two: Using the default JS array sort default sort, is sorted by ASCII;
To follow the ascending order of the following:< console printout >
1. Sort the current array first
2. Check that the element I is currently in is the same as the last element in the temporary array because it is already sorted, so the repeating element is in the adjacent position
3. If it is not the same, the element is stored in the result array
Way three:< recommended > Using JSON objects for property values
1. Create a new array to hold the result
2. Create an empty object json
3.for Loop, each time an element is taken out and compared to the object, if the element is not duplicated, it is stored in the result array, and the content of the element as an object property, and assigned a value of 1, deposited in the 2nd step of the object created.
Note: As for how to compare, it is to remove an element from the original array, and then go to the object to access the property, if you can access the value, then the description is repeated.
Array removal repetition in JavaScript