Skip to content

Instantly share code, notes, and snippets.

@crittelmeyer
Forked from inPhoenix/isEmpty
Created January 21, 2022 23:44
Show Gist options
  • Save crittelmeyer/7df1b3fd07ffb66a433bfc9e8c1dc179 to your computer and use it in GitHub Desktop.
Save crittelmeyer/7df1b3fd07ffb66a433bfc9e8c1dc179 to your computer and use it in GitHub Desktop.
Alternative to lodash _.isEmpty
const isEmpty = value => {
return (
value == null || // From standard.js: Always use === - but obj == null is allowed to check null || undefined
(typeof value === 'object' && Object.keys(value).length === 0) ||
(typeof value === 'string' && value.trim().length === 0)
)
}
export default isEmpty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment