How do I take doubles out of an array?

I have an array with numbers. Each number resembles a card in a deck. A deck in my game can have multiple copies of the same card.

Now I have finally made an album in which the player can view all their unlocked cards. However, if a player has a lot of doubles, they see the unlocked card multiple times in the album.

This does not matter for developing. The album just shows 8 cards at the time and then the player can choose to see the next 8, or the previous 8. This loops till the end of the array is reached.

But for the player, it is probably a pain in the neck to see all those double cards. It bothers me during testplay, so it might bother my players as well.

So, I want to use a clone of the array containing their unlocked cards, and then take all the doubles out. I already did everything as planned, accept for that last step.

How do I remove all doubles from an array?
The array is sorted in numeric order, so doubles are right next to each-other, if that helps.
Array.from(new Set([your array elements here]))

Or if your MV's version supports it:

[...new Set([your array elements here])]
Would something like this work ?

Code:
unique_array = base_array.filter(function(v,ind,arr) {
            return arr.indexOf(v) === ind;
        });

It is something I used to replace the "unique" method we had in ruby.
Array.from(new Set([your array elements here]))

Or if your MV's version supports it:

[...new Set([your array elements here])]
Awesome, thanks.

Would something like this work ?

Code:
unique_array = base_array.filter(function(v,ind,arr) {
            return arr.indexOf(v) === ind;
        });

It is something I used to replace the "unique" method we had in ruby.
Thanks. I didn't test this one. Trihan's method works, and is shorter than yours, so that is the one I went with. Thanks anyway. 🙂
The Set method is significantly more performant than filter-index as well. As per Christian on StackOverflow:

"Comparing performance of .filter+indexOf and the Set-approach in Chrome 100 revealed that for an array with numbers and length 0 to 120 the filter-approach is even faster. With array length 200 the filter-approach takes 50% more time than with a Set (6 vs. 9 microseconds). For 5000 elements the filter operation takes over 3 milliseconds while Set still copes with my example in 173 microseconds. So "much slower", really depends on the use case. If someone is interested I can post the data as a separate Q&A."

(which is really only a concern for larger arrays; for a deck of cards it's negligible to the point of irrelevance)
This thread is being closed due to being solved. If you need it reopened, report it to let us know why. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-take-doubles-out-of-an-array.164398/