-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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