Licence
ISC
Version
2.0.0
Deps
0
Vulns
0
Weekly
0
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 {}; // object
typeof /a/; // object
typeof null; // object
typeof []; // object
typeof new String('foo'); // object
Installation
npm install --save better-typeof
Usage
const betterTypeof = require('better-typeof');
betterTypeof({}); // object
betterTypeof(/a/); // regexp
betterTypeof(null); // null
betterTypeof([]); // array
betterTypeof(new String('foo')); // string