better-typeof
v2.0.0
Published
Like typeof, but not awful.
Downloads
7
Readme
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