type-of

Type assertions aka less-broken typeof.

npm install type-of
29 downloads in the last day
129 downloads in the last week
669 downloads in the last month

type-of

Type assertions aka less-broken typeof.

Build Status Dependency Status NPM version

browser support

Example

var type = require('type-of')

var obj = new Date
if (type(obj) == 'date') ...

API

type(new Date) == 'date'
type({}) == 'object'
type(null) == 'null'
type(undefined) == 'undefined'
type("hey") == 'string'
type(true) == 'boolean'
type(false) == 'boolean'
type(12) == 'number'
type(type) == 'function'
type(/asdf/) == 'regexp'
type((function(){ return arguments })()) == 'arguments'
type([]) == 'array'
type(document.createElement('div')) == 'element'

License

MIT

npm loves you