Node module. typeOf('a string') == 'string', typeOf([]) == 'array', etc.. Also supports named functions detections aka javascript classes

npm install typeof
1 downloads in the last day
2 downloads in the last week
21 downloads in the last month


Small node.js module that dramatically extends functionality of native typeof

Inspired by Batman.js typeOf util

UPD: now it returns lowercased name of any javascript class. Thanks to @BallBearing for idea


$ npm install typeof
var typeOf = require('typeof');

console.log(typeOf("a string"));
// -> "string"

console.log(typeOf([1, 2, 3, "array"]));
// -> "array"

// -> "null"

console.log(typeOf(new Buffer(0)));
// -> "buffer"

function MyClass() {
  this.is = "class constructor"  
console.log(typeOf(new MyClass));
// ->"myclass"
npm loves you