Skip to content

Instantly share code, notes, and snippets.

@MatthewDaniels
Last active March 16, 2016 21:51
Show Gist options
  • Save MatthewDaniels/46efbe437e82e079a1b7 to your computer and use it in GitHub Desktop.
Save MatthewDaniels/46efbe437e82e079a1b7 to your computer and use it in GitHub Desktop.
A better typeof implementation
/**
* A better typeof implementation.<br>
* This method will return a proper string for
* every object in javascript; including, but not limited to:
* 'array'
* 'arguments'
* 'error'
* 'date'
* 'regexp'
* 'json'
* .
* .
* .
*/
window.toType = window.toType || function(a) { return ({}).toString.call(a).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment