Skip to content

Instantly share code, notes, and snippets.

@mmazer
Created February 24, 2012 16:00
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 mmazer/1901762 to your computer and use it in GitHub Desktop.
Save mmazer/1901762 to your computer and use it in GitHub Desktop.
JavaScript: A replacement for JavaScript typeof
// Based on http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
function toType(obj) {
return ( {} ).toString.call( obj ).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