Example 1 — Official: Remove Repeated Numbers
Keep the first copy of each value. A number and a string are never the same value.
console.log(R.uniq([1, 1, 2, 1])); // [1, 2]
console.log(R.uniq([1, '1'])); // [1, '1'] How It Works
- First 1. Not seen yet, so it is kept.
- Second and fourth 1. Already seen, so both are dropped.
- 2. New, so it is kept after the 1:
[1, 2]. - 1 vs '1'.
R.equals(1, '1')isfalsebecause the types differ, so both stay.
