2.0.0 • Published 8 years ago
better-typeof v2.0.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'); // objectInstallation
npm install --save better-typeofUsage
const betterTypeof = require('better-typeof');
betterTypeof({}); // object
betterTypeof(/a/); // regexp
betterTypeof(null); // null
betterTypeof([]); // array
betterTypeof(new String('foo')); // string