Skip to content

Instantly share code, notes, and snippets.

@dikmenonur
Last active July 12, 2021 07:46
Show Gist options
  • Save dikmenonur/2046e6c266e1af58dee0aeea048538be to your computer and use it in GitHub Desktop.
Save dikmenonur/2046e6c266e1af58dee0aeea048538be to your computer and use it in GitHub Desktop.
javascript_isnull.js
function IsNotEmpty(val) {
if (val === undefined)
return false;
if (typeof (val) == 'function' || typeof (val) == 'number' || typeof (val) == 'boolean' || Object.prototype.toString.call(val) === '[object Date]')
return true;
if (val == null || val.length === 0) // null or 0 length array
return false;
if (typeof (val) == "object") {
// empty object
var r = false;
for (var f in val) {
if (Object.prototype.hasOwnProperty.call(val, f)) {
r = true;
}
}
return r;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment