kind-of

Get the native type of a value.

Install

Install with npm:

npm i kind-of --save-dev

Run tests

npm test

Usage

var kindOf = require('kind-of');

kindOf(undefined);
//=> 'undefined'

kindOf(null);
//=> 'null'

kindOf(true);
//=> 'boolean'

kindOf(false);
//=> 'boolean'

kindOf(new Boolean(true));
//=> 'boolean'

kindOf(42);
//=> 'number'

kindOf(new Number(42));
//=> 'number'

kindOf("string");
//=> 'string'

kindOf(arguments);
//=> 'arguments'

kindOf({});
//=> 'object'

kindOf(new Test());
//=> 'object'

kindOf(new Date());
//=> 'date'

kindOf([]);
//=> 'array'

kindOf([1, 2, 3]);
//=> 'array'

kindOf(new Array());
//=> 'array'

kindOf(/[\s\S]+/);
//=> 'regexp'

kindOf(new RegExp('^' + 'foo$'));
//=> 'regexp'

kindOf(function () {});
//=> 'function'

kindOf(new Function());
//=> 'function'

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license

This file was generated by verb-cli on October 26, 2014.

Last updated