Skip to content

Instantly share code, notes, and snippets.

@jens1101
Created November 21, 2016 07:09
Show Gist options
  • Select an option

  • Save jens1101/7cbb2dda1458eed8963a3f7cd72cfda2 to your computer and use it in GitHub Desktop.

Select an option

Save jens1101/7cbb2dda1458eed8963a3f7cd72cfda2 to your computer and use it in GitHub Desktop.
Easily check if a variable is null or undefined
function isNullOrUndefined(variable) {
// We use '==' instead of '===', because it will automatically cast the varaible to null
// if it is undefined. There are no other side-effects, so this is one of the few cases
// where the use of '==' is justified.
return variable == null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment