Update top JS snippets

This commit is contained in:
Chalarangelo
2021-10-13 20:09:28 +03:00
parent 2b775e3c93
commit 3cd481c0d1
19 changed files with 45 additions and 43 deletions

View File

@ -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