Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created April 17, 2014 12:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/8a15454f9594cd373e13 to your computer and use it in GitHub Desktop.
Save tommcfarlin/8a15454f9594cd373e13 to your computer and use it in GitHub Desktop.
[JavaScript] An example of how to use an optional parameter to detect if a variable is define
function acmeReferenceError( valueExists ) {
'use strict';
if ( undefined === valueExists ) {
/* If this is hit, then the function is being invoked
* before the variable in question has been defined.
*/
} else {
/* If this particular conditional is hit, then the function
* is being invoked after the value in question has
* been defined.
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment