Skip to content

Instantly share code, notes, and snippets.

@jmorenoamor
Created April 5, 2020 07:13
Show Gist options
  • Save jmorenoamor/432f4b9dd709dc2f5b3d4153e9c98a00 to your computer and use it in GitHub Desktop.
Save jmorenoamor/432f4b9dd709dc2f5b3d4153e9c98a00 to your computer and use it in GitHub Desktop.
Removes all the occurences of a particular property from an object
/*
* Removes all the occurences of a particular property from an object
*/
function stripeObject(obj, property="_meta") {
Object.keys(obj).forEach(k => {
if (typeof obj === "object") {
if (k === property) {
delete obj[k];
} else {
obj[k] = stripeObject(obj[k]);
}
}
});
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment