is-nullish

Test a value for nullishness.

Usage no npm install needed!

<script type="module">
  import isNullish from 'https://cdn.skypack.dev/is-nullish';
</script>

README

node-is-nullish

NPM Package Build Status Coverage Status Dependency Status

Example

var isNull = require("is-nullish");
isNull("");
//true
isNull(0);
//false

Installation

npm i is-nullish

Usage

Differences between falsy, is-nullish, and is-empty:

value typeof value Boolean(value) isNull(value) isEmpty(value)
not defined "undefined" false true true
undefined "undefined" false true true
null "object" false true true
"" "string" false true true
NaN "number" false true false
0 "number" false false true
false "boolean" false false false
{} "object" true true* true
[] "object" true true* true
function () {} "function" true true* true
*Objects and functions are nullish unless they have non-nullish enumerable properties.

API Reference

isNull(value) ⇒ boolean

Kind: Exported function
Params

  • value *

Example

var f = function (x) { return x; };
isNull(f);
//true
f.objective = "objectify";
isNull(f);
//false

License

MPL 2.0