Skip to content

Instantly share code, notes, and snippets.

@frivolta
Last active January 10, 2020 13:32
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 frivolta/2cb6f6cce5de2480d9c35bee6a519711 to your computer and use it in GitHub Desktop.
Save frivolta/2cb6f6cce5de2480d9c35bee6a519711 to your computer and use it in GitHub Desktop.
// Add a new generic type T
const filterArrayByValue = <T>(
items: T[],
propertyName: string,
valueToFilter: string
): T[] => {
return items.filter(item =>item[propertyName] === valueToFilter);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment