Design & Download
Your JS Library
in Seconds!!!

Snippet: isNil()

Written by Christopher West (cwest) on August 08, 2016.
Determine if a value is null or undefined.
function isNil(value) {
  return value == undefined;
}

isNil(...) API Documentation

Description

Determines if a value is either null or undefined.

Parameters

  1. value {*}:
    The value to be checked.

Returns

Returns true if value is either null or undefined. Otherwise false is returned.

Example

console.log(YourJS.isNil());  // -> true
console.log(YourJS.isNil(null));  // -> true
console.log(YourJS.isNil(undefined));  // -> true
console.log(YourJS.isNil(void 0));  // -> true
console.log(YourJS.isNil(NaN));  // -> false
console.log(YourJS.isNil(''));  // -> false
console.log(YourJS.isNil(0));  // -> false