Skip to content

Instantly share code, notes, and snippets.

@bcls
Created August 23, 2017 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcls/9a22ccc20dddbf3da5382e3b3f87a4f5 to your computer and use it in GitHub Desktop.
Save bcls/9a22ccc20dddbf3da5382e3b3f87a4f5 to your computer and use it in GitHub Desktop.
isdefined() #javascript
/**
* tests for all the ways a variable might be undefined or not have a value
* @param {*} x the variable to test
* @return {Boolean} true if variable is defined and has a value
*/
function isDefined(x) {
if ( x === '' || x === null || x === undefined) {
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment