Skip to content

Instantly share code, notes, and snippets.

@MateusAndrade
Created September 10, 2019 14:57
Show Gist options
  • Save MateusAndrade/bf9f5595f7b005865b476111eac8d7c9 to your computer and use it in GitHub Desktop.
Save MateusAndrade/bf9f5595f7b005865b476111eac8d7c9 to your computer and use it in GitHub Desktop.
A simple function to remove obj keys
const removeObjKeys: <T>(obj: T, keys: string[]) => T = (obj, keys) => {
const objectKeys: string[] = Object.keys(obj);
keys.forEach((key: string) => {
const isPresentKey = objectKeys.find((objKey: string) => objKey === key);
if (isPresentKey) {
delete obj[key];
}
});
return obj;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment