Skip to content

Instantly share code, notes, and snippets.

@inPhoenix
Last active February 28, 2024 16:36
Show Gist options
  • Save inPhoenix/45a9f9e2568126d206f1125caebcd122 to your computer and use it in GitHub Desktop.
Save inPhoenix/45a9f9e2568126d206f1125caebcd122 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
@uhelliton-megawhat
Copy link

Nice..

@kimumu-asia
Copy link

Great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment