Skip to content

Instantly share code, notes, and snippets.

@think49
Created March 9, 2011 12:15
Show Gist options
  • Save think49/862098 to your computer and use it in GitHub Desktop.
Save think49/862098 to your computer and use it in GitHub Desktop.
get-class.js : [[Class]] を返す (ECMAScript5準拠)
/**
* 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