Skip to content

Instantly share code, notes, and snippets.

@ruan4261
Last active Jun 30, 2021
Embed
What would you like to do?
/**
* 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