Skip to content

Instantly share code, notes, and snippets.

@tytskyi
Last active August 29, 2015 14:05
Show Gist options
  • Save tytskyi/dba22116deec08dfde0a to your computer and use it in GitHub Desktop.
Save tytskyi/dba22116deec08dfde0a to your computer and use it in GitHub Desktop.
type = (function(global) {
var re = /\s([a-z|A-Z]+)/;
return function(obj) {
if (obj === global) {
return 'global';
}
return Object.prototype.toString.call(obj).match(re)[1].toLowerCase();
}
})(window);
type('123');
type(123);
type(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment