2.0.0 • Published 6 years ago

better-typeof v2.0.0

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

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