Skip to content

Instantly share code, notes, and snippets.

@weslleyaraujo
Created September 29, 2014 22:39
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 weslleyaraujo/d1e74800f85587b166f3 to your computer and use it in GitHub Desktop.
Save weslleyaraujo/d1e74800f85587b166f3 to your computer and use it in GitHub Desktop.
function TypeOf () {
return Object.prototype.toString.call(this)
.replace(/(\bobject\b\s)/g, '')
.replace(/\[/g, '')
.replace(/\]/g, '')
.toLowerCase();
};
console.log(TypeOf.call({})); // object
console.log(TypeOf.call([])) // array
console.log(TypeOf.call(TypeOf)) // function
console.log(TypeOf.call(1)) // number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment