When we work large datasets, removing duplicates is a critical technique to work with unique values.
How does this remove duplicates?
The `filter()` checks whether the current item’s index matches the **first occurrence** of that item in the array. If it doesn’t, it’s a duplicate and gets filtered out.
Is this case-sensitive?
Yes — `”Apple”` and `”apple”` are treated as different strings. If you want to make it case-insensitive, you can normalize the items:
Can I use this with numbers too?
Yes! This approach works for arrays of numbers as well:
Is this the most efficient way?
For small to medium arrays, yes. For larger datasets, using a `Set` is faster and cleaner: