Last active
July 12, 2021 07:46
-
-
Save dikmenonur/2046e6c266e1af58dee0aeea048538be to your computer and use it in GitHub Desktop.
javascript_isnull.js
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
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