DEV Community

Discussion on: JavaScript: How to Remove Duplicate Values from Arrays

Collapse
lukaszahradnik profile image
Lukáš Zahradník • Edited on

Hi, your benchmark is wrong for indexOf where you are taking all duplicate values instead of unique ones (wrong comparison). Those approaches will perform differently depending on duplicates density - reduce is not necessarily faster.

Both versions are O(n^2).