Last active
June 30, 2021 06:49
-
-
Save ruan4261/675203c9c2aa62142937ff7b131609ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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