Skip to content

Instantly share code, notes, and snippets.

@vandorjw
Created March 26, 2016 19:06
Show Gist options
  • Select an option

  • Save vandorjw/bdcb4437b35121cf40d1 to your computer and use it in GitHub Desktop.

Select an option

Save vandorjw/bdcb4437b35121cf40d1 to your computer and use it in GitHub Desktop.
Javascript - Check if variable is null
/* * *
* 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