How to remove duplicates from an array in JavaScript? [duplicate]

I want to transform this array into a new array that contains only unique values. I’ve tried a few methods, but I’m not sure which one is the most efficient and commonly used in modern JavaScript.
Using a For Loop: I manually checked each element and pushed unique values to a new array.This works but feels cumbersome and might not be the most efficient approach.
Using Set: I learned that Set automatically removes duplicates, so I tried this:This method is concise and leverages modern JavaScript features, but I’m curious about its performance compared to other methods.
Using Filter: I also tried using filter() with indexOf():This approach also works but involves using the indexOf method, which might not be the most efficient for large arrays.
Using Reduce: I found another method using reduce() to accumulate unique values:This method is more functional and leverages reduce(), but I’m not sure if it offers any performance benefits over the other methods.