Skip to content

Instantly share code, notes, and snippets.

@tomaszgil
Last active March 25, 2022 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaszgil/d2bd853e25ff41429daab27b2a8814ec to your computer and use it in GitHub Desktop.
Save tomaszgil/d2bd853e25ff41429daab27b2a8814ec to your computer and use it in GitHub Desktop.
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