Created
August 26, 2018 06:30
-
-
Save suissa/dbe2ed4d7d4d505b3ac9893ddc98180a to your computer and use it in GitHub Desktop.
JavaScript - groupby - filter 02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const toGroup = (field, value) => (obj) => | |
obj[field] === value | |
const filtered = list.filter(toGroup("level", "senior")) | |
console.log({filtered}) | |
/** | |
{ filtered: | |
[ { id: 1, | |
name: 'Suissa', | |
active: true, | |
level: 'senior', | |
tags: [Array] }, | |
{ id: 2, | |
name: 'Bella', | |
active: true, | |
level: 'senior', | |
tags: [Array] }, | |
{ id: 3, | |
name: 'Joana', | |
level: 'senior', | |
active: true, | |
tags: [Array] } ] } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment