What
better-typeof
is a single JavaScript function that returns the type of a value. This is mainly a learning exercise. You should probably use kind-of instead.
Why
The native JavaScript typeof
operator is drunk and will shout "object"
at almost any value you give it.
typeof {};
typeof /a/;
typeof null;
typeof [];
typeof new String('foo');
Installation
npm install --save better-typeof
Usage
const betterTypeof = require('better-typeof');
betterTypeof({});
betterTypeof(/a/);
betterTypeof(null);
betterTypeof([]);
betterTypeof(new String('foo'));