Created
March 26, 2016 19:06
-
-
Save vandorjw/bdcb4437b35121cf40d1 to your computer and use it in GitHub Desktop.
Javascript - Check if variable is null
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
| /* * * | |
| * takes any object as input and checks whether it's value is null. | |
| * null is the only primitive value that is 'falsy' but also returns | |
| * "object" from the typeof check. | |
| */ | |
| function is_null(obj) { | |
| return (!obj && typeof obj === "object"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment