Skip to content

Instantly share code, notes, and snippets.

@akinolu52
Created April 4, 2019 15:13
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 akinolu52/cdbe5c2c043e23bb477721dd0cb6a72c to your computer and use it in GitHub Desktop.
Save akinolu52/cdbe5c2c043e23bb477721dd0cb6a72c to your computer and use it in GitHub Desktop.
let k = {
x: ['mi', 'ko'],
y: []
}
function clean(obj) {
for (let propName in obj) {
if (obj.hasOwnProperty(propName)) {
if (!obj[propName].length) {
delete obj[propName];
}
}
}
}
console.log(clean(k))
console.log(k)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment