Remove Duplicates from JavaScript Array

Posted by kramden88 on Stack Overflow See other posts from Stack Overflow or by kramden88
Published on 2012-02-10T14:53:22Z Indexed on 2012/06/30 3:16 UTC
Read the original article Hit count: 247

This seems like such a simple need but I've spent an inordinate amount of time trying to do this to no avail. I've looked at other questions on SO and I haven't found what I need. I have a very simple JavaScript array such as peoplenames = new Array("Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"); that may or may not contain duplicates and I need to simply remove the duplicates and put the unique values in a new array. That's it. I could point to all the codes that I've tried but I think it's useless because they don't work. If anyone has done this and can help me out I'd really appreciate it. JavaScript or jQuery solutions are both acceptable.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about arrays