Skip to content

Instantly share code, notes, and snippets.

@bhaireshm
Last active February 24, 2025 09:26
Show Gist options
  • Save bhaireshm/f3e08002cc67f42f5e77eb7ce606c09b to your computer and use it in GitHub Desktop.
Save bhaireshm/f3e08002cc67f42f5e77eb7ce606c09b to your computer and use it in GitHub Desktop.
To check whether the value of any variable is empty.
/**
* @param data - any datatype value.
*/
function isEmpty(data) {
if (typeof data == "number" || typeof data == "boolean") return false;
if (typeof data == "undefined" || data === null) return true;
if (typeof data.length != "undefined") return data.length == 0;
let count = 0;
for (let i in data) if (data.hasOwnProperty(i)) count++;
return count == 0;
}
@bhaireshm
Copy link
Author

ez.js is more than just a library; it's a coding companion that simplifies complex tasks. Whether you're dealing with arrays, numbers, objects, or strings, ez.js has got your back! Say goodbye to coding hassles and hello to streamlined JavaScript magic.

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