There is a small library that checks for JavaScript types: is.js
is.json({foo: 'bar'}); => true // functions are returning as false is.json(toString); => false is.not.json([]); => true is.all.json({}, 1); => false is.any.json({}, 2); => true // 'all' and 'any' interfaces can also take array parameter is.all.json([{}, {foo: 'bar'}]); => true
Actually, is.js is much more than some, some of which deserve mention:
var obj = document.createElement('div'); is.domNode(obj); => true is.error(new Error()); => true is.function(toString); => true is.chrome(); => true if current browser is chrome
Ramazan Polat Feb 23 '19 at 0:20 2019-02-23 00:20
source share