We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7810899 commit ecf6030Copy full SHA for ecf6030
README.md
@@ -135,3 +135,26 @@ myArray.flat(2) // [2, 3, 4, 5 ,7,7, 8, 9, [1, 1]]
135
myArray.flat(infinity) // [2, 3, 4, 5 ,7,7, 8, 9, 1, 1];
136
137
```
138
+
139
+#Get unique values in an array
140
141
+```javascript
142
+const numbers = [1,1,3,2,5,3,4,7,7,7,8];
143
144
+//Ex1
145
+const unieqNumbers = numbers.filter((v,i,a) => a.indexOf(v )=== i )
146
+console.log(unieqNumbers) //[1,3,2,5,4,7,8]
147
148
+//Ex2
149
+const unieqNumbers2 = Array.from(new Set(numbers))
150
+console.log(unieqNumbers2) //[1,3,2,5,4,7,8]
151
152
+//Ex3
153
+const unieqNumbers3 = [...new Set(numbers)]
154
+console.log(unieqNumbers3) //[1,3,2,5,4,7,8]
155
156
+//EX4 lodash
157
+const unieqNumbers4 = _.uniq(numbers)
158
+console.log(unieqNumbers4) //[1,3,2,5,4,7,8]
159
160
+```
0 commit comments