Skip to content

Instantly share code, notes, and snippets.

@ruan4261
Last active June 30, 2021 06:49
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 ruan4261/675203c9c2aa62142937ff7b131609ab to your computer and use it in GitHub Desktop.
Save ruan4261/675203c9c2aa62142937ff7b131609ab to your computer and use it in GitHub Desktop.
/**
* Only for String and ArrayLike.
* Return false if parameter is an object.
*
* @return {boolean}
*/
function isEmpty(obj) {
return (
obj === undefined ||
obj === null ||
Number(obj.length) === 0 ||
(typeof obj === "string" && obj.trim().length === 0)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment