Last active
March 16, 2016 21:51
-
-
Save MatthewDaniels/46efbe437e82e079a1b7 to your computer and use it in GitHub Desktop.
A better typeof implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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