Created
March 9, 2011 12:15
-
-
Save think49/862098 to your computer and use it in GitHub Desktop.
get-class.js : [[Class]] を返す (ECMAScript5準拠)
This file contains hidden or 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
/** | |
* get-class.js | |
* | |
* @version 1.0.4 | |
* @author think49 | |
* @url https://gist.github.com/862098 | |
*/ | |
function getClass (arg) { | |
var _class; | |
if (arg === null) { // Null Type | |
return null; | |
} | |
switch (typeof arg) { | |
case 'undefined': // Undefined Type | |
case 'boolean': // Boolean Type | |
case 'number': // Number Type | |
case 'string': // String Type | |
_class = null; | |
break; | |
default: // Object Type | |
_class = Object.prototype.toString.call(arg).slice(8, -1); | |
break; | |
} | |
return _class; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment