Don't you think that might a bit overcomplicated for the OP? He's obviously just getting into Javascript. Then again, he could just copy-paste and let the magic function do its trick, but that's not very helpful or in the spirit of good learning...
–
Elliot BonnevilleMar 17 '12 at 16:02

It's a complex thing to be doing just if you are just starting out. I assumed he needed a copy-paste solution.
–
nathanjosiahMar 17 '12 at 16:03

You can remove dups from an array by using a temporary hash table (using a javascript object) to keep track of which images you've already seen in the array. This works for array values that can be uniquely represented as a string (strings or numbers mostly), but not for objects.

First of all, you'll want to use the array literal (var output = []) to declare your array. Second, you'll want to loop through your array and store all the values in a second array. If any value in the first array matches a value in the second array, delete it and continue looping.

Can I ask the reason for the unexplained downvote? It's just a simple, readable, and easy way of finding duplicate values for a beginner in Javascript who obviously doesn't need a complicated and overworked solution.
–
Elliot BonnevilleMar 17 '12 at 16:01

I didn't downvote, but you're both incrementing iand deleting items. You'll be missing elements that way, unless you decrement i a well when splicing an element.
–
pimvdbMar 17 '12 at 16:05

Oops, yeah, I should have used a reverse loop. My bad, thanks for the catch.
–
Elliot BonnevilleMar 17 '12 at 16:06

In fact I think you meant to change valueIsInArray to true and to actually populate doubledOutput...
–
pimvdbMar 17 '12 at 16:08

Guilty as charged. I wrote up the code really quickly so as to get the answer in before somebody else... doesn't help that I haven't had my coffee yet either. Fixing all counts. :)
–
Elliot BonnevilleMar 17 '12 at 16:10