Skip to content

Instantly share code, notes, and snippets.

@metavoid
Created February 10, 2019 21:26
Show Gist options
  • Select an option

  • Save metavoid/c5df6f4a7d18870e317fa758d72dfe13 to your computer and use it in GitHub Desktop.

Select an option

Save metavoid/c5df6f4a7d18870e317fa758d72dfe13 to your computer and use it in GitHub Desktop.
Check if Object or Array is empty in JS
//Check if Object or Array is empty
function isEmpty(obj) {
if (Array.isArray(obj) && obj.length > 0) return false;
if (typeof obj === 'object' && Object.keys(obj).length > 0) return false;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment