Update top JS snippets
This commit is contained in:
@ -2,12 +2,12 @@
|
||||
title: uniqueElementsBy
|
||||
tags: array,intermediate
|
||||
firstSeen: 2018-07-18T20:49:07+03:00
|
||||
lastUpdated: 2020-10-22T20:24:44+03:00
|
||||
lastUpdated: 2021-10-13T19:29:39+02:00
|
||||
---
|
||||
|
||||
Finds all unique values of an array, based on a provided comparator function.
|
||||
|
||||
- Use `Array.prototype.reduce()` and `Array.prototype.some()` for an array containing only the first unique occurrence of each value, based on the comparator function, `fn`.
|
||||
- Use `Array.prototype.reduce()` and `Array.prototype.some()` to create an array containing only the first unique occurrence of each value, based on the comparator function, `fn`.
|
||||
- The comparator function takes two arguments: the values of the two elements being compared.
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user