A NPM module to validate or fetch type of given argument in javascript.
npm install javascript-type-checker --save
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isArray(['A','B',3])); // true
console.log(javascriptTypeChecker.isArray('A')); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isObject({'key':'value'})); // true
console.log(javascriptTypeChecker.isObject(['A','B',3])); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isNumber(123)); // true
console.log(javascriptTypeChecker.isNumber('123')); // false
console.log(javascriptTypeChecker.isNumber(NaN)); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isError(new Error('Test Error'))); // true
console.log(javascriptTypeChecker.isError('Test Error')); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isString('123')); // true
console.log(javascriptTypeChecker.isString(123)); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isBoolean(false)); // true
console.log(javascriptTypeChecker.isBoolean('false')); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isNull(null)); // true
console.log(javascriptTypeChecker.isNull('ABC')); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isUndefined({}.testKey)); // true
console.log(javascriptTypeChecker.isUndefined({})); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isEmptyObject({})); // true
console.log(javascriptTypeChecker.isEmptyObject({'key':'value'})); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isEmptyArray([])); // true
console.log(javascriptTypeChecker.isEmptyArray(['A'])); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isArrayOfEmptyArrays([[[[]], [[]]], [])); // true
console.log(javascriptTypeChecker.isArrayOfEmptyArrays([[[[[]]]], 'A'])); // false
const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.getType('123')); // string
console.log(javascriptTypeChecker.getType(123)); // number
console.log(javascriptTypeChecker.getType(true)); // boolean
console.log(javascriptTypeChecker.getType(NaN)); // NaN
console.log(javascriptTypeChecker.getType(null)); // null
console.log(javascriptTypeChecker.getType(undefined)); // undefined
console.log(javascriptTypeChecker.getType({})); // object
console.log(javascriptTypeChecker.getType([])); // array
console.log(javascriptTypeChecker.getType(new Error('test'))); // error