Skip to content

Instantly share code, notes, and snippets.

@stavros-zavrakas
Created March 17, 2016 00:09
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 stavros-zavrakas/ee7a1d6686312da6415b to your computer and use it in GitHub Desktop.
Save stavros-zavrakas/ee7a1d6686312da6415b to your computer and use it in GitHub Desktop.
Get type
var objectPrototype = Object.prototype;
function getType(val) {
return objectPrototype.toString.apply(val).match(/\[object\s(\w+)\]/)[1];
}
getType("Stavros");
getType(true);
getType(24);
getType([]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment