How to filter repeated elements in an array using javascript,
How to filter repeated elements in an array using javascript
The following documents are available for use in projects. For details, refer:
Implementation Code:
Function filterArray (receiveArray) {var arrResult = new Array (); // defines an Array of returned results. for (var I = 0; I <receiveArray. length; ++ I) {if (check (arrResult, receiveArray [I]) =-1) {// here, the I element is the same as the arrResult for all judgments. push (receiveArray [I]); // Add this element to the new array. If the value in if is false (that is, it has already been added), // No .}} Return arrResult;} function check (receiveArray, checkItem) {var index =-1; // the return value of the function is used for Boolean judgment for (var I = 0; I <receiveArray. length; ++ I) {if (receiveArray [I] = checkItem) {index = I; break ;}} return index ;}
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!