Skip to content

Instantly share code, notes, and snippets.

@bcls
bcls / isdefined.js
Created August 23, 2017 19:45
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;