var-defined
Tired of doing this?
if a && ab && abc && abcd && abcde // do something
Usage
Pass a variable to either of the 3 utility functions. Optionally pass a deep test for arrays and objects. See example below.
- defined - returns boolean for whether a variable is defined
- truthy - returns boolean for whether a variable is truthy
- isset - returns boolean for whether a variable is defined and not null (much like PHP isset)
;/* or ES5: var defined = require('var-defined').defined; ...*/ const test = a: true b: '' c: d: undefined e: 'hello' false f: null; ; // true; // true; // true ; // true; // false; // false ; // false; // false; // false ; // false; // true; // true
Installation
NPM
$ npm install var-defined
YARN
$ yarn add var-defined
License
MIT