Created
November 21, 2016 07:09
-
-
Save jens1101/7cbb2dda1458eed8963a3f7cd72cfda2 to your computer and use it in GitHub Desktop.
Easily check if a variable is null or undefined
This file contains hidden or 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 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