How do I remove duplicates from a comma delimited string of integers using jquery/javascript?
My string is: 1,2,2,4,2,4,3,2,3,1,5,5,5,1,1,2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For one method, which doesn’t demand writing the functionality from scratch or using some other js library check out duck-punching-with-jquery. (look for ‘Example 2: $.unique() enhancement’)
If you’re willing to try some other library, the excellent underscorejs includes a ‘uniq‘ method which accomplishes just what you need.