Skip to content

Instantly share code, notes, and snippets.

@ivan-demchenko
Last active August 29, 2015 13:56
Show Gist options
  • Save ivan-demchenko/8912213 to your computer and use it in GitHub Desktop.
Save ivan-demchenko/8912213 to your computer and use it in GitHub Desktop.
Get the real type of a value
/**
* Thanks to Dmitry Baranovsky for his knowledge sharing:
* http://dmitry.baranovskiy.com/post/typeof-and-friends
*/
function is (value) {
return {
aan: function (type) {
type = String(type).toLowerCase();
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase() === type;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment