Skip to content

Instantly share code, notes, and snippets.

@Om4ar
Forked from richardkundl/Common-isEmpty.js
Created February 8, 2018 12:26
Show Gist options
  • Save Om4ar/153ea49dffb51401fb44e1b465525658 to your computer and use it in GitHub Desktop.
Save Om4ar/153ea49dffb51401fb44e1b465525658 to your computer and use it in GitHub Desktop.
Javascript is empty function
// Current value is empty
this.isEmpty = function(value){
return value == null // NULL value
|| value == undefined // undefined
|| value == 'undefined' // undefined
|| value.length == 0 // Array is empty
|| value == '00000000-0000-0000-0000-000000000000' // Guid empty
|| ((value instanceof Date && !isNaN(value.valueOf())) // Validate DateTime value and check min-max value
&& ((value <= new Date(1753, 01, 01)) // SQL DateTime minimum value
|| (value >= new Date(9999, 12, 31, 23, 59, 59, 999))) // SQL DateTime maximum value
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment