is-nullish
v1.0.0
Published
Test a value for nullishness.
Downloads
83
Readme
node-is-nullish
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