Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

type-of

2.0.1 • Public • Published

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

Keywords

none

install

npm i type-of

Downloadsweekly downloads

56,401

version

2.0.1

license

none

repository

githubgithub

last publish

collaborators

  • avatar