Skip to content

Instantly share code, notes, and snippets.

@klauskpm
Created January 29, 2014 21:44
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 klauskpm/8697832 to your computer and use it in GitHub Desktop.
Save klauskpm/8697832 to your computer and use it in GitHub Desktop.
Functions to know if the variable is defined and to set a default value if not.
function defaultIfUndefined(variable, value) {
return isUndefined(variable)?value:variable;
}
function isUndefined(variable) {
return typeof(variable)=='undefined';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment