Skip to content

Instantly share code, notes, and snippets.

@FireNeslo
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FireNeslo/0e31d7cbc0c7935fe9de to your computer and use it in GitHub Desktop.
Save FireNeslo/0e31d7cbc0c7935fe9de to your computer and use it in GitHub Desktop.
A better typeof function
function typeOf(object) {
if(object && "name" in object.constructor) {
return object.constructor.name;
}
if(typeof object === 'number' && object !== object) {
return 'NaN';
}
var type = Object.prototype.toString.call(object);
return type.substring(8,type.length-1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment