Last active
March 25, 2022 21:23
-
-
Save tomaszgil/d2bd853e25ff41429daab27b2a8814ec to your computer and use it in GitHub Desktop.
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 data = { | |
other: 'skip', | |
prefix1: 'take1', | |
prefix2: 'take2', | |
}; | |
const prefixedValues = Object.entries(data) | |
// Get only entries with keys staring with prefix | |
.filter(([key, value]) => key.startsWith('prefix')) | |
// Get only values | |
.map(([key, value]) => value); | |
console.log(prefixedValues); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment